How to use MJRefresh
- Installation with CocoaPods:
pod 'MJRefresh'
- Manual import:
- Drag All files in the
MJRefresh
folder to project - Import the main file:
#import "MJRefresh.h"
- Drag All files in the
Base Custom
MJRefresh.bundle MJRefresh.h
MJRefreshConst.h MJRefreshConst.m
UIScrollView+MJExtension.h UIScrollView+MJExtension.m
UIScrollView+MJRefresh.h UIScrollView+MJRefresh.m
UIView+MJExtension.h UIView+MJExtension.m
- More information of App can focus on:M了个J-博客园
The Class Structure Chart of MJRefresh
The class of red text
in the chart:You can use them directly- The drop-down refresh control types
- Normal:
MJRefreshNormalHeader
- Gif:
MJRefreshGifHeader
- Normal:
- The pull to refresh control types
- Auto refresh
- Normal:
MJRefreshAutoNormalFooter
- Gif:
MJRefreshAutoGifFooter
- Normal:
- Auto Back
- Normal:
MJRefreshBackNormalFooter
- Gif:
MJRefreshBackGifFooter
- Normal:
- Auto refresh
- The drop-down refresh control types
The class of non-red text
in the chart:For inheritance,to use DIY the control of refresh- About how to DIY the control of refresh,You can refer the Class in below Chart
MJRefreshComponent.h
/** The Base Class of refresh control */
@interface MJRefreshComponent : UIView
#pragma mark - Control the state of Refresh /** BeginRefreshing */
- (void)beginRefreshing;
/** EndRefreshing */
- (void)endRefreshing;
/** IsRefreshing */
- (BOOL)isRefreshing; #pragma mark - Other
/** According to the drag ratio to change alpha automatically */
@property (assign, nonatomic, getter=isAutomaticallyChangeAlpha) BOOL automaticallyChangeAlpha;
@end
MJRefreshHeader.h
@interface MJRefreshHeader : MJRefreshComponent
/** Creat header */
+ (instancetype)headerWithRefreshingBlock:(MJRefreshComponentRefreshingBlock)refreshingBlock;
/** Creat header */
+ (instancetype)headerWithRefreshingTarget:(id)target refreshingAction:(SEL)action; /** This key is used to storage the time that the last time of drown-down successfully */
@property (copy, nonatomic) NSString *lastUpdatedTimeKey;
/** The last time of drown-down successfully */
@property (strong, nonatomic, readonly) NSDate *lastUpdatedTime; /** Ignored scrollView contentInset top */
@property (assign, nonatomic) CGFloat ignoredScrollViewContentInsetTop;
@end
MJRefreshFooter.h
@interface MJRefreshFooter : MJRefreshComponent
/** Creat footer */
+ (instancetype)footerWithRefreshingBlock:(MJRefreshComponentRefreshingBlock)refreshingBlock;
/** Creat footer */
+ (instancetype)footerWithRefreshingTarget:(id)target refreshingAction:(SEL)action; /** NoticeNoMoreData */
- (void)noticeNoMoreData;
/** ResetNoMoreData(Clear the status of NoMoreData ) */
- (void)resetNoMoreData; /** Ignored scrollView contentInset bottom */
@property (assign, nonatomic) CGFloat ignoredScrollViewContentInsetBottom; /** Automaticlly show or hidden by the count of data(Show-have data,Hidden- no data) */
@property (assign, nonatomic) BOOL automaticallyHidden;
@end
MJRefreshAutoFooter.h
@interface MJRefreshAutoFooter : MJRefreshFooter
/** Is Automatically Refresh(Default is Yes) */
@property (assign, nonatomic, getter=isAutomaticallyRefresh) BOOL automaticallyRefresh; /** When there is much at the bottom of the control is automatically refresh(Default is 1.0,Is at the bottom of the control appears in full, will refresh automatically) */
@property (assign, nonatomic) CGFloat triggerAutomaticallyRefreshPercent;
@end
Reference
* Due to there are more functions of this framework,Don't write specific text describe its usage
* You can directly reference examples MJTableViewController、MJCollectionViewController、MJWebViewController,More intuitive and fast.
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:15];
header.lastUpdatedTimeLabel.font = [UIFont systemFontOfSize:14]; // 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:17]; // 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
}];
Remind
- ARC
- iOS>=6.0
- iPhone \ iPad screen anyway
How to use MJRefresh的更多相关文章
- MJRefresh 源码解读 + 使用
MJRefresh这个刷新控件是一款非常好用的框架,我们在使用一个框架的同时,最好能了解下它的实现原理,不管是根据业务要求在原有的基础上修改代码,还是其他的目的,弄明白作者的思路和代码风格,会受益匪浅 ...
- 关于MJRefresh的下拉加载数据bug
当没有更多数据的时候显示NoMoreData 我的理解是先结束刷新再显示没有更多 今天之前一直没发现有问题 贴之前的代码 [self.collectionView reloadData]; [self ...
- iOS MJRefresh设置MJRefreshStateNoMoreData状态图片
MJRefresh地址 // 代码地址: https://github.com/CoderMJLee/MJRefresh// 代码地址: http://code4app.com/ios/%E5%B ...
- 使用MJRefresh遇到的一个问题,上拉刷新后tableview瞬间滑到最底部
最近用MJRefresh上拉刷新时遇到一个问题,就是上拉刷新后,tableview会瞬间滑到最底部,用户还要往回翻才能看到新刷出来的数据,体验十分不好.查了很久没找到原因,最后发现在refreshvi ...
- MJRefresh自定义刷新动画
[一]常见用法 最原始的用法,耦合度低,但是不能统一管理.我们需要在每一个控制器都写以下代码,很繁琐,以后项目修改起来更繁琐,得一个控制器一个控制器的去定位.修改. 1.1 使用默认刷新(耦合度底,但 ...
- MJRefresh下拉刷新框架
github下载地址:https://github.com/CoderMJLee/MJRefresh MJRefresh类结构图 self.userTableView.mj_footer = [MJR ...
- iOS MJRefresh下拉刷新(上拉加载)使用详解
下拉刷新控件目前比较火的有好几种,本人用过MJRefresh 和 SVPullToRefresh,相对而言,前者比后者可定制化.拓展新都更高一点. 因此本文着重讲一下MJRefresh的简单用法. 导 ...
- iOS开发——常见错误——使用MJRefresh返回上一个界面蹦掉的情况
最近在使用MJRefresh框架时发现了一个bug 下面是我的源代码 前一个界面 -(void)tableView:(UITableView *)tableView didSelectRowAtInd ...
- MJRefresh的一个注意事项
如果从视图一跳转到视图二之后,在视图二中进行MJRefresh的刷新操作,那么在推出试图二之前要用dealloc函数将MJRefreshHeaderView或者MJRefreshFooterView释 ...
- 正在使用MJRefresh & MJExtension的App
框架地址:https://github.com/CoderMJLee已经有上百个App用到了MJRefresh & MJExtension框架(只列出了其中一部分App):
随机推荐
- JavaScript_7_运算符
1. 算术运算符 2. 赋值运算符 3. 用于字符串的+运算 如果把字符串与数字相加,结果将成为字符串 <!DOCTYPE html> <html> <head> ...
- Android(java)学习笔记115:BroadcastReceiver之 Android广播机制
Android广播机制 android系统中有各式各样的广播,各种广播在Android系统中运行,当"系统/应用"程序运行时便会向Android注册各种广播.Android接收到广 ...
- Processing一些常用技巧
一些常用技巧总结: Tweak模式 快速查找函数用法 显示与输入中文注释 代码快速对齐 批量添加注释符 Tweak模式 Tweak模式是非常有用的功能,自3.0版本后,它就正式整合到Processin ...
- js倒计时小插件(兼容大部分浏览器)
精确到天的倒计时 <script language="JavaScript"> <!-- // (c) Henryk Gajewski var urodz= ne ...
- Dojo的define接口
http://blog.csdn.net/lovecarpenter/article/details/53979717 第三种用法用的最多. 此接口用于定义模块: define([],function ...
- 有关SQL的一道面试题
这是一个学生分数表 StudentName StudySubject SubjectScore Peter ...
- sql 经典加强巩固练习题
由于本人需要加强巩固一下数据库知识,就搜罗了一些题目来练习,感觉不错,故分享一下资源难度层度依次上升这50道里面自认为应该没有太多错误,而且尽可能使用了最简单或是最直接的查询,有多种不相上下解法的题目 ...
- 解决Windows 与Mac 双系统下的蓝牙设备共用的问题
不知道有多少人和我一样用的蓝牙鼠标或者键盘,有的话应该都会遇到同一个问题:即在一个系统下配好对后在另一个系统必须重新配对才能使用,很是麻烦.还要将蓝牙设备进入发现模式,OS下搜索,连接....终于昨天 ...
- 字节跳动后端开发实习生面试(Python)
一面: 1.自我介绍. 2.介绍“工大小美”项目相关. 3.Python中的GIL(全局解释器锁),以及哪种情况下使用python的多线程性能有较大的提升. 4.项目中用到了SQLite数据库,如果有 ...
- 一些恶搞人的c++程序
top1: 不停打开的cmd(磁盘操作系统) 代码如下: #include<windows.h> using namespace std; int main() { system(&quo ...