这里是我使用的代码:如何判断UITableView是否包含特定的NSIndexPath?
if (appDelegate.currentMainIndexPath != nil /* && doesPathExistInTableView */)
{
[tblView scrollToRowAtIndexPath:appDelegate.currentMainIndexPath atScrollPosition:UITableViewScrollPositionTop animated:NO];
appDelegate.currentMainIndexPath = nil;
}
为什么这是公认的答案?该代码甚至不是有效的Objective-C,即使您修复了编译错误,如果单元格不可见,仍然会使用返回nil的方法,这意味着您无法滚动到某个不是“ t已经在屏幕上,并且滚动的全部点是使不可见的东西。 –