UITableView实现下拉刷新添加数据功能

来源:互联网 发布:linux 网络流量监控 编辑:程序博客网 时间:2024/05/16 01:21

用UITableViewDelegate中的这个方法:

- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath;


判定tableView中的数组数是否即将显示最后一个cell,if (indexPath.row == [self.dataArr count]-1) 

想在下边加个视图的话,可以这么做:

在UITableView中的tableFooterView里

self.tableView.tableFooterView = footSpinnerView;//footSpinnerView为自定义的UIView,上面加了一个旋转的 UIActivityIndicatorView即可,记得让UIActivityIndicatorView startAnimation


加上你关于刷新数组的逻辑,如从数据库中取出更多的数据,取完数据后,将self.tableView.tableFooterView设nil即可。