- (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];
}
});
}
以上代碼之前滑動(dòng)到底部還可以屈张,最近發(fā)現(xiàn)滑不到最底部咽扇。
解決辦法:
_tableView.estimatedRowHeight = 0;
_tableView.estimatedSectionFooterHeight = 0;
_tableView.estimatedSectionHeaderHeight = 0;