手动调用 didSelectRowAtIndexPath 时出现异常
Exception when manually calling didSelectRowAtIndexPath
我正在尝试在 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];
}
我看不到可以明确设置该部分的地方。
有什么建议吗?谢谢!
使用这个:
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:row inSection:section];
使用 UITableView 还需要指定 NSIndexPath 部分
NSIndexPath* indexPath = [NSIndexPath indexPathForRow:row inSection:section];
我正在尝试在 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];
}
我看不到可以明确设置该部分的地方。
有什么建议吗?谢谢!
使用这个:
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:row inSection:section];
使用 UITableView 还需要指定 NSIndexPath 部分
NSIndexPath* indexPath = [NSIndexPath indexPathForRow:row inSection:section];