的UITableView不会滚动到细胞
我试图滚动我的tableview到第二小区:的UITableView不会滚动到细胞
[self.tableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:1 inSection:0]
atScrollPosition:UITableViewScrollPositionNone
animated:NO];
我得到的错误:
*** Terminating app due to uncaught exception 'NSRangeException', reason: '-[UITableView scrollToRowAtIndexPath:atScrollPosition:animated:]: section (1) beyond bounds (0).
'
我tableview中有30个细胞那些没有部分出现。
如果你没有的部分,那么你可以尝试indexPathWithIndex:
类的构造函数:
[self.tableView scrollToRowAtIndexPath:[NSIndexPath indexPathWithIndex:1]
atScrollPosition:UITableViewScrollPositionNone
animated:NO];
该调用在4.0中不推荐使用。我知道我们不能讨论它,所以如果不打破NDA,我怎么能指定一个部分,如果我不包含任何? – 2010-05-26 13:58:56
@Sheehan:我看不到XCode,头文件或文档中的弃用警告。你确定这个电话已被弃用吗? – 2010-05-26 14:34:30
对不起,我错了,不推荐使用。我确实得到这个错误: ***终止应用程序,由于未捕获的异常'NSInternalInconsistencyException',原因:'与UITableView一起使用的索引路径无效。传递给表视图的索引路径必须包含恰好两个指定节和行的索引。如果可能,请在UITableView.h中使用NSIndexPath上的类别。' – 2010-05-26 15:04:28
我建议你创建一个部分,将细胞储存在该节可以没有标题,使其看起来并不区分。 ,这对你来说有什么好处,就是不必打击预期的API途径。
NSIndexPath *ip = [NSIndexPath indexPathForRow:itemCurrentlyPlaying inSection:0];
这并不容易找到,但相关的便捷构造:
当我有一个部分台同样的错误消息,我用两行和部分创建一个NSIndexPath固定它这里记载:
像pollyp,我能够使用indexPathForRow:inSection:
。我从我的viewWillAppear:
打电话给我。
它看起来像你的错误信息是说,甚至没有一节。您是否可以在载入表格数据之前调用scrollToRowAtIndexPath:atScrollPosition:animated:
(例如,在viewDidLoad
)?请稍后尝试拨打电话,地址为viewWillAppear:
。
显示'numberOfSectionsInTableView'的代码:' – 2010-06-01 20:07:07