- (void)scrollToBottom{
if ([self.tableView numberOfSections] == 0 || self.tableView.decelerating || self.tableView.tracking) {
return;
}
NSIndexPath *lastCell = [NSIndexPath indexPathForItem:([self.tableView numberOfRowsInSection:0] - 1) inSection:0];
[self scrollToIndexPath:lastCell animated:YES];
}
- (void)scrollToIndexPath:(NSIndexPath *)indexPath animated:(BOOL)animated
{
if ([self.tableView numberOfSections] <= indexPath.section) {
return;
}
NSInteger numberOfItems = [self.tableView numberOfRowsInSection:indexPath.section];
if (numberOfItems == 0) {
return;
}
NSInteger item = MAX(MIN(indexPath.item, numberOfItems - 1), 0);
indexPath = [NSIndexPath indexPathForItem:item inSection:0];
[self.tableView scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionTop animated:animated];
}
TableView滚动道底部安全的处理方案
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
推荐阅读更多精彩内容
- 扯谈: 在实际开发工作中,你是否体会过自己无意识中就写了好多重复的代码?然后,感叹自己写的代码不够看啊。在实际开发...