iOS UITableView滑动到底部

- (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;
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容