tableView加载完毕后回调的delegate方法:
-(void) tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
if([indexPath row] == ((NSIndexPath*)[[tableView indexPathsForVisibleRows] lastObject]).row){
//end of loading
//for example [activityIndicator stopAnimating];
}
}
++++++++++++++++++++++++++++++++++++++
由于willDisplayCell是异步调用的,所以在上面的block里面不能即时更新UI,最好使用GCD通过主线程加上你的代码:
-(void) tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
if([indexPath row] == ((NSIndexPath*)[[tableView indexPathsForVisibleRows] lastObject]).row){
//end of loading
dispatch_async(dispatch_get_main_queue,^{
//for example [activityIndicator stopAnimating];
});
}
}