使用CocoaPods加载三方库:

pod 'MJRefresh'

MJRefresh类结构图:

具体实现方法和效果图:

  • The drop-down refresh 01-Default

    self.tableView.header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
    //Call this Block When enter the refresh status automatically
    }];

    // Set the callback(Once you enter the refresh status,then call the action of target,that is call [self loadNewData])
    self.tableView.header = [MJRefreshNormalHeader headerWithRefreshingTarget:self refreshingAction:@selector(loadNewData)]; // Enter the refresh status immediately
    [self.tableView.header beginRefreshing];

  • The drop-down refresh 02-Animation image

    // Set the callback(一Once you enter the refresh status,then call the action of target,that is call [self loadNewData])
    MJRefreshGifHeader *header = [MJRefreshGifHeader headerWithRefreshingTarget:self refreshingAction:@selector(loadNewData)];
    // Set the ordinary state of animated images
    [header setImages:idleImages forState:MJRefreshStateIdle];
    // Set the pulling state of animated images(Enter the status of refreshing as soon as loosen)
    [header setImages:pullingImages forState:MJRefreshStatePulling];
    // Set the refreshing state of animated images
    [header setImages:refreshingImages forState:MJRefreshStateRefreshing];
    // Set header
    self.tableView.mj_header = header;

  • The drop-down refresh 03-Hide the time

    // Hide the time
    header.lastUpdatedTimeLabel.hidden = YES;

  • The drop-down refresh 04-Hide status and time

    // Hide the time
    header.lastUpdatedTimeLabel.hidden = YES; // Hide the status
    header.stateLabel.hidden = YES;

  • The drop-down refresh 05-DIY title

    // Set title
    [header setTitle:@"Pull down to refresh" forState:MJRefreshStateIdle];
    [header setTitle:@"Release to refresh" forState:MJRefreshStatePulling];
    [header setTitle:@"Loading ..." forState:MJRefreshStateRefreshing]; // Set font
    header.stateLabel.font = [UIFont systemFontOfSize:];
    header.lastUpdatedTimeLabel.font = [UIFont systemFontOfSize:]; // Set textColor
    header.stateLabel.textColor = [UIColor redColor];
    header.lastUpdatedTimeLabel.textColor = [UIColor blueColor];

  • The drop-down refresh 06-DIY the control of refresh

    self.tableView.mj_header = [MJDIYHeader headerWithRefreshingTarget:self refreshingAction:@selector(loadNewData)];
    // Implementation reference to MJDIYHeader.h和MJDIYHeader.m

  • The pull to refresh 01-Default

    self.tableView.mj_footer = [MJRefreshAutoNormalFooter footerWithRefreshingBlock:^{
    //Call this Block When enter the refresh status automatically
    }];

    // Set the callback(Once you enter the refresh status,then call the action of target,that is call [self loadMoreData])
    self.tableView.mj_footer = [MJRefreshAutoNormalFooter footerWithRefreshingTarget:self refreshingAction:@selector(loadMoreData)];

  • The pull to refresh 02-Animation image

    // Set the callback(Once you enter the refresh status,then call the action of target,that is call [self loadMoreData])
    MJRefreshAutoGifFooter *footer = [MJRefreshAutoGifFooter footerWithRefreshingTarget:self refreshingAction:@selector(loadMoreData)]; // Set the refresh image
    [footer setImages:refreshingImages forState:MJRefreshStateRefreshing]; // Set footer
    self.tableView.mj_footer = footer;

  • The pull to refresh 03-Hide the title of refresh status

    // Hide the title of refresh status
    footer.refreshingTitleHidden = YES;
    // If does have not above method,then use footer.stateLabel.hidden = YES;

  • The pull to refresh 04-All loaded

    //Become the status of NoMoreData
    [footer noticeNoMoreData];

  • The pull to refresh 05-DIY title

    // Set title
    [footer setTitle:@"Click or drag up to refresh" forState:MJRefreshStateIdle];
    [footer setTitle:@"Loading more ..." forState:MJRefreshStateRefreshing];
    [footer setTitle:@"No more data" forState:MJRefreshStateNoMoreData]; // Set font
    footer.stateLabel.font = [UIFont systemFontOfSize:]; // Set textColor
    footer.stateLabel.textColor = [UIColor blueColor];

  • The pull to refresh 06-Hidden After loaded

    //Hidden current control of the pull to refresh
    self.tableView.mj_footer.hidden = YES;

  • The pull to refresh 07-Automatic back of the pull01

    self.tableView.mj_footer = [MJRefreshBackNormalFooter footerWithRefreshingTarget:self refreshingAction:@selector(loadMoreData)];

  • The pull to refresh 08-Automatic back of the pull02

    MJRefreshBackGifFooter *footer = [MJRefreshBackGifFooter footerWithRefreshingTarget:self refreshingAction:@selector(loadMoreData)];
    
    // Set the normal state of the animated image
    [footer setImages:idleImages forState:MJRefreshStateIdle];
    // Set the pulling state of animated images(Enter the status of refreshing as soon as loosen)
    [footer setImages:pullingImages forState:MJRefreshStatePulling];
    // Set the refreshing state of animated images
    [footer setImages:refreshingImages forState:MJRefreshStateRefreshing]; // Set footer
    self.tableView.mj_footer = footer;

  • The pull to refresh 09-DIY the control of refresh(Automatic refresh)

    self.tableView.mj_footer = [MJDIYAutoFooter footerWithRefreshingTarget:self refreshingAction:@selector(loadMoreData)];
    // Implementation reference to MJDIYAutoFooter.h和MJDIYAutoFooter.m

  • The pull to refresh 10-DIY the control of refresh(Automatic back)

    self.tableView.mj_footer = [MJDIYBackFooter footerWithRefreshingTarget:self refreshingAction:@selector(loadMoreData)];
    // Implementation reference to MJDIYBackFooter.h和MJDIYBackFooter.m

  • UICollectionView01-The pull and drop-down refresh

    // The drop-down refresh
    self.collectionView.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
    //Call this Block When enter the refresh status automatically
    }]; // The pull to refresh
    self.collectionView.mj_footer = [MJRefreshAutoNormalFooter footerWithRefreshingBlock:^{
    //Call this Block When enter the refresh status automatically
    }];

  • UIWebView01-The drop-down refresh

    //Add the control of The drop-down refresh
    self.webView.scrollView.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
    //Call this Block When enter the refresh status automatically
    }];

文章来源:https://github.com/CoderMJLee/MJRefresh

iOS-加载数据的实现-MJRefresh的更多相关文章

  1. ios ableviewcell的动态加载数据,模仿喜马拉雅动态数据加载

    iphone(UITableViewCell)动态加载图片http://developer.apple.com/library/ios/#samplecode/LazyTableImages/Intr ...

  2. iOS PickerView动态加载数据

    将新的数据放入临时数组 NSMutableArray *tmp=[[NSMutableArray alloc] init]; [tmp addObject:[[NSString alloc] init ...

  3. iOS开发——网络Swift篇&NSURLSession加载数据、下载、上传文件

    NSURLSession加载数据.下载.上传文件   NSURLSession类支持三种类型的任务:加载数据.下载和上传.下面通过样例分别进行介绍.   1,使用Data Task加载数据 使用全局的 ...

  4. Bootstrap-Select 动态加载数据的小记

    关于前端框架系列的可以参考我我刚学Bootstrap时候写的LoT.UI http://www.cnblogs.com/dunitian/p/4822808.html#lotui bootstrap- ...

  5. winform异步加载数据到界面

    做一个学习记录. 有两个需求: 1.点击按钮,异步加载数据,不卡顿UI. 2.把获取的数据加载到gridview上面. 对于需求1,2,代码如下: public delegate void ShowD ...

  6. Ajax 加载数据 练习 自我有些迷糊了,写的大概请谅解 ^ _ ^

    查询表的显示,查询显示如果不嵌入PHP代码的话,用ajax怎么实现?   <h1>显示数据</h1> <table width="100%" bord ...

  7. 分页插件思想:pc加载更多功能和移动端下拉刷新加载数据

    感觉一个人玩lol也没意思了,玩会手机,看到这个下拉刷新功能就写了这个demo! 这个demo写的比较随意,咱不能当做插件使用,基本思想是没问题的,要用就自己封装吧! 直接上代码分析下吧! 布局: & ...

  8. 使用 jQuery Ajax 在页面滚动时从服务器加载数据

    简介 文本将演示怎么在滚动滚动条时从服务器端下载数据.用AJAX技术从服务器端加载数据有助于改善任何web应用的性能表现,因为在打开页面时,只有一屏的数据从服务器端加载了,需要更多的数据时,可以随着用 ...

  9. 向上滚动或者向下滚动分页异步加载数据(Ajax + lazyload)[上拉加载组件]

    /**** desc : 分页异步获取列表数据,页面向上滚动时候加载前面页码,向下滚动时加载后面页码 ajaxdata_url ajax异步的URL 如data.php page_val_name a ...

  10. AppCan学习笔记----关闭页面listview动态加载数据

    AppCan页面关闭 AppCan 的页面是由两个HTML组成,如果要完全关闭的话需要在主HTML eg.index.html中关闭,关闭方法:appcan.window.close(-1); 管道 ...

随机推荐

  1. 第 2 章 Python 语言入⻔

    目录 2.1低而长的学习曲线 2.2Python的优势 2.3在你的计算机中安装Python 2.4如何运行Python程序 2.5文本编辑器 2.6寻求帮助 Python语言是一种流行的编程语言,在 ...

  2. C#使用Json.NET解析Json

    本文转载自 http://xiaosheng.me/2016/10/01/article25/ 最近在 C# 项目中需要使用到 Json 格式的数据,我简单上网搜索了一下,基本上有两种操作 Json ...

  3. 【转】Subversion快速入门教程-动画演示

    如何快速建立Subversion服务器,并且在项目中使用起来,这是大家最关心的问题,与CVS相比,Subversion有更多的选择,也更加的容易,几个命令就可以建立一套服务器环境,可以使用起来,这里配 ...

  4. NetCore 学习笔记(DI 实例生命周期)

    Transient: 每一次GetService都会创建一个新的实例 Scoped:    在同一个Scope内只初始化一个实例,同一个请求内只会被创建一次 Singleton :整个应用程序生命周期 ...

  5. bzoj4514: [Sdoi2016]数字配对(费用流)

    传送门 ps:费用流增广的时候费用和流量打反了……调了一个多小时 每个数只能参与一次配对,那么这就是一个匹配嘛 我们先把每个数分解质因数,记质因子总个数为$cnt_i$,那如果$a_i/a_j$是质数 ...

  6. 解读人:李思奇,Development of a sensitive, scalable method for spatial, cell-type-resolved proteomics of the human brain. (一种用于研究人类大脑基于空间或细胞类型的蛋白质组学的灵敏方法)

    发表时间:(2019年4月) 一. 概述: 本文报道了一种可研究人类大脑组织中特定神经细胞的蛋白质组学的方法.作者通过激光捕获显微切割技术(LCM)从逝者大脑中分离出目的神经元细胞,接着尝试了一系列不 ...

  7. 洛谷P2911 [USACO08OCT]牛骨头Bovine Bones【水题】

    题目大意:输入S1,S2,S3,随机生成三个数x,y,z,求x+y+z出现次数最多的数(如果有多个答案输出最小的),其中1<=x<=S1,1<=y<=S2,1<=z< ...

  8. > Task :app:transformDexArchiveWithExternalLibsDexMergerForDebug FAILED

    > Task :app:transformDexArchiveWithExternalLibsDexMergerForDebug FAILED D8: Cannot fit requested ...

  9. Zabbix之CentOS7.3下yum安装Zabbix3.5

    Zabbix特点介绍 (此介绍来源于https://www.zabbix.com/documentation/3.4/zh/manual/introduction/features) 概述Zabbix ...

  10. 1095 Cars on Campus(30 分

    Zhejiang University has 8 campuses and a lot of gates. From each gate we can collect the in/out time ...