2012-07-27 98 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] 
相关问题