• Installation with CocoaPods:pod 'MJRefresh'
  • Manual import:
    • Drag All files in the MJRefresh folder to project
    • Import the main file:#import "MJRefresh.h"
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

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
    • The pull to refresh control types
      • Auto refresh

        • Normal:MJRefreshAutoNormalFooter
        • Gif:MJRefreshAutoGifFooter
      • Auto Back
        • Normal:MJRefreshBackNormalFooter
        • Gif:MJRefreshBackGifFooter
  • 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的更多相关文章

  1. MJRefresh 源码解读 + 使用

    MJRefresh这个刷新控件是一款非常好用的框架,我们在使用一个框架的同时,最好能了解下它的实现原理,不管是根据业务要求在原有的基础上修改代码,还是其他的目的,弄明白作者的思路和代码风格,会受益匪浅 ...

  2. 关于MJRefresh的下拉加载数据bug

    当没有更多数据的时候显示NoMoreData 我的理解是先结束刷新再显示没有更多 今天之前一直没发现有问题 贴之前的代码 [self.collectionView reloadData]; [self ...

  3. iOS MJRefresh设置MJRefreshStateNoMoreData状态图片

    MJRefresh地址 //  代码地址: https://github.com/CoderMJLee/MJRefresh//  代码地址: http://code4app.com/ios/%E5%B ...

  4. 使用MJRefresh遇到的一个问题,上拉刷新后tableview瞬间滑到最底部

    最近用MJRefresh上拉刷新时遇到一个问题,就是上拉刷新后,tableview会瞬间滑到最底部,用户还要往回翻才能看到新刷出来的数据,体验十分不好.查了很久没找到原因,最后发现在refreshvi ...

  5. MJRefresh自定义刷新动画

    [一]常见用法 最原始的用法,耦合度低,但是不能统一管理.我们需要在每一个控制器都写以下代码,很繁琐,以后项目修改起来更繁琐,得一个控制器一个控制器的去定位.修改. 1.1 使用默认刷新(耦合度底,但 ...

  6. MJRefresh下拉刷新框架

    github下载地址:https://github.com/CoderMJLee/MJRefresh MJRefresh类结构图 self.userTableView.mj_footer = [MJR ...

  7. iOS MJRefresh下拉刷新(上拉加载)使用详解

    下拉刷新控件目前比较火的有好几种,本人用过MJRefresh 和 SVPullToRefresh,相对而言,前者比后者可定制化.拓展新都更高一点. 因此本文着重讲一下MJRefresh的简单用法. 导 ...

  8. iOS开发——常见错误——使用MJRefresh返回上一个界面蹦掉的情况

    最近在使用MJRefresh框架时发现了一个bug 下面是我的源代码 前一个界面 -(void)tableView:(UITableView *)tableView didSelectRowAtInd ...

  9. MJRefresh的一个注意事项

    如果从视图一跳转到视图二之后,在视图二中进行MJRefresh的刷新操作,那么在推出试图二之前要用dealloc函数将MJRefreshHeaderView或者MJRefreshFooterView释 ...

  10. 正在使用MJRefresh & MJExtension的App

    框架地址:https://github.com/CoderMJLee已经有上百个App用到了MJRefresh & MJExtension框架(只列出了其中一部分App):

随机推荐

  1. FlowVisor相关

    1. FlowVisor工作原理(转) 作为一个网络虚拟化平台,FlowVisor部署在标准OpenFlow控制器和OpenFlow交换机之间,成为二者的透明代理.FlowVisor能够与多个控制器连 ...

  2. MySql5.7主从配置

    记录 环境:ubuntu16.04,mysql5.7 主机:192.168.1.240,192.168.1.241:241为Salve 1.安装mysql sudo apt-get install m ...

  3. Cocos2d-x——导入Cocostudio资源

    (搬运自我在SegmentFault的博客) 目前正在和实训的小组成员一起做一款手机2D游戏,我们采用了Cocos2d-x进行开发.之前虽然早有耳闻,这次却是第一次认真地学习和使用Cocos2d-x. ...

  4. UVALive 4329 Ping pong (BIT)

    枚举中间的人,只要知道在这个人前面的技能值比他小的人数和后面技能值比他小的人数就能计算方案数了,技能值大的可有小的推出. 因此可以利用树状数组,从左到右往树上插点,每个点询问sum(a[i]-1)就是 ...

  5. python_87_shelve模块

    'shelve模块是一个简单的key,value将内存数据通过文件持久化的模块,可以持久化任何pickle可支持的python数据格式(只支持pickle)' #序列化,将数据写入文件 import ...

  6. Paper: 《Bert》

    Bert: Bidirectional Encoder Representations from Transformers. 主要创新点:Masked LM 和 Next sentence predi ...

  7. pysql用类进行封装

    pyMySQL用类进行封装 class SqlHelper(object): def __init__(self): self.connect() def connect(self): self.co ...

  8. vs 2012打开vs2013的sln

    Project -> Properties -> General -> Platform Toolset (as IInspectable correctly commented)

  9. Java中如果把构造方法也私有化,如何创建对象?Java的单例设计模式——饿汉式和懒汉式区别

    Java的单例模式——饿汉式 package com.swift; //Java单例设计模式——恶汉式 public class SinglePerson { private String name= ...

  10. javascript设计模式(张容铭)学习笔记 - 外观模式绑定事件

    有一个需求要为document对象绑定click事件来是想隐藏提示框的交互功能,于是小白写了如下代码: document.onclick = function(e) { e.preventDefaul ...