2012-07-27 102 views
6

我需要手動以編程方式在我的tableView上觸發單元格選擇。本質上運行的預發功能手動觸發單元格選擇TableView

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 

我爲了做這個項目時被刪除,從它的tableView會自動加載下一個項目。但是,當我嘗試手動調用此函數時,它似乎無法找到。我試過

self.tableView: didSelectRowAtIndexPath 

[tableView didSelectRowAtIndexPath] 

但既不是公認的。

回答

5
[self tableView:self.tableView didSelectRowAtIndexPath:selectedIndexPath]; 

取代selectedIndexPath與任何下一行是

確保自我是你的表視圖委託

編輯:我知道這是一個老問題,但實際上這應該 [tableView selectRowAtIndexPath:path animated:YES scrollPosition:UITableViewScrollPositionMiddle];

完成
+0

如何選擇下一個indexPath,例如如果選擇第1行我想選擇第0行 – jskrwyk 2012-07-27 16:21:09

+0

您可以使用[NSIndexPath indexPathForRow:whateverRow inSection:whateverSection]創建索引路徑;使用任何你喜歡的行和部分的邏輯 – wattson12 2012-07-27 17:04:20

1

您應該嘗試:

[self tableView:self.tableView didSelectRowAtIndexPath:YourIndexPath] 
相關問題