- (void)scrollToBottom:(BOOL)animate{
if (!self.isScroll) return;
self.isScroll = NO;
NSInteger numberOfSections = [self.datasource numberOfSections];
NSInteger numberOfRows = [self.datasource numberOfRowsInSection:(numberOfSections-1)];
if (!numberOfSections) {
return;
}
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:(numberOfRows - 1) inSection:(numberOfSections - 1)];
dispatch_async(dispatch_get_main_queue(), ^{
if (indexPath.section < self.datasource.numberOfSections && indexPath.row < [self.datasource numberOfRowsInSection:indexPath.section]) {
[self.tableView scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionBottom animated:animate];
}
});
}
以上代码之前滑动到底部还可以,最近发现滑不到最底部。
解决办法:
_tableView.estimatedRowHeight = 0;
_tableView.estimatedSectionFooterHeight = 0;
_tableView.estimatedSectionHeaderHeight = 0;