03 UITableView 刚进来的时候无法滚动到到底部

162 阅读1分钟

#####1. 原因: 页面加载过来,数据没有加载完成

#####2. 解决方法: 使用异步函数,等TableView加载完成,就不会出现滑不到底部的问题了

    dispatch_async(dispatch_get_main_queue(), ^{
        NSIndexPath *indexPath = [NSIndexPath indexPathForRow:self.datas.count - 1 inSection:0];
        [self.tableView scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionBottom animated:YES];
    });