TableView滚动道底部安全的处理方案
作者:
李木的 | 来源:发表于
2017-03-24 17:16 被阅读11次- (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滚动道底部安全的处理方案
本文链接:https://www.haomeiwen.com/subject/zzpfottx.html
网友评论