我正在尝试在 UITableview 上手动调用 didSelectRowAtIndexPath。这样做时出现以下异常:
'Invalid index path for use with UITableView. Index paths passed to table view must contain exactly two indices specifying the section and row.
这是导致异常的代码:
-(void)refreshLayerAtIndexPath:(NSUInteger)index {
NSIndexPath* indexPath = [[NSIndexPath alloc] initWithIndex:index];
[self tableView:_tableViewLayers didSelectRowAtIndexPath:indexPath];
}
我看不到任何地方可以明确设置该部分。
有什么建议吗?谢谢!
最佳答案
使用 UITableView 还需要指定 NSIndexPath 的部分
NSIndexPath* indexPath = [NSIndexPath indexPathForRow:row inSection:section];
关于ios - 手动调用 didSelectRowAtIndexPath 时出现异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30515741/