美文网首页UITableView
IOS - 判断UITableView首次加载完成

IOS - 判断UITableView首次加载完成

作者: 囧rg | 来源:发表于2017-08-22 19:18 被阅读410次

在sdk中,的确没有UITableView首次加载完成Cell的回调方法。
在代理的方法中,也是没有的。
不过我们可以使用下面的方法,来判断加载完成。
由于willDisplayCell是异步调用的,所以在上面的block里面不能即时更新UI,最好使用GCD通过主线程加上你的代码:

-(void) tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
    if([indexPath row] == ((NSIndexPath*)[[tableView indexPathsForVisibleRows] lastObject]).row){
        dispatch_async(dispatch_get_main_queue(),^{
            NSLog(@"加载完成!!!");
        });
    }
}

相关文章

网友评论

本文标题:IOS - 判断UITableView首次加载完成

本文链接:https://www.haomeiwen.com/subject/roaldxtx.html