iOS 添加上拉加载

用UITableViewDelegate中的这个方法:

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

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

如果是的话,self.tableView.tableFooterView = footSpinnerView;//footSpinnerView为自定义的UIView,上面加了一个旋转的UIActivityIndicatorView即可,记得让UIActivityIndicatorView startAnimation加上刷新数组的逻辑,取完数据后,将self.tableView.tableFooterView设nil即可。

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

{

    if (indexPath.row == [self.productArr count]-1) {

    self.tableView.tableFooterView = footSpinnerView;

    //添加数据源

    }

}

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

推荐阅读更多精彩内容

  • 概述在iOS开发中UITableView可以说是使用最广泛的控件,我们平时使用的软件中到处都可以看到它的影子,类似...
    liudhkk阅读 9,085评论 3 38
  • { 24、Sqlite数据库 1、存储大数据量,增删改查,常见管理系统:Oracle、MSSQLServer、DB...
    CYC666阅读 959评论 0 1
  • 版权声明:未经本人允许,禁止转载. 1. TableView初始化 1.UITableView有两种风格:UITa...
    萧雪痕阅读 2,915评论 2 10
  • #pragma mark someValueAboutTableView 1.tableView的样式:UITab...
    潇岩阅读 947评论 0 0
  • 曾经深夜一通电话把对方叫醒的朋友,曾经拉出来撸串喝酒谈人生理想的朋友……现在一顿饭,却永远约在“改天”。人和人之间...
    罗掌柜real阅读 162评论 0 0