MJRefresh-fork 3.2.1

MJRefresh-fork 3.2.1

suger 维护。



  • MJ Lee

(logo)

MJRefresh

podversion

  • 一个简单的下拉刷新方式

内容

支持哪些控件刷新

  • UIScrollViewUITableViewUICollectionViewUIWebView

如何使用 MJRefresh

  • 使用 CocoaPods 安装:pod 'MJRefresh'
  • 使用 Carthage 安装:github "CoderMJLee/MJRefresh"
  • 手动导入:
    • MJRefresh 文件夹下的所有文件拖到项目中
    • 导入主文件:#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

超过数百个应用已使用 MJRefresh

* 更多关于应用的详细信息,可以关注:[M了个J-博客园](http://www.cnblogs.com/mjios/p/4409853.html)

MJRefresh 类结构图

  • 图表中红色字体的类:您可以直接使用它们
    • 下拉刷新控件类型
      • 普通:MJRefreshNormalHeader
      • Gif:MJRefreshGifHeader
    • 上拉刷新控件类型
      • 自动刷新
        • 普通:MJRefreshAutoNormalFooter
        • Gif:MJRefreshAutoGifFooter
      • 自动回弹
        • 普通:MJRefreshBackNormalFooter
        • Gif:MJRefreshBackGifFooter
  • 图表中非红色字体的类:用于继承,用于自定义刷新控件
  • 关于如何自定义刷新控件,可以参考以下图表中的类

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;
@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.

下拉刷新 01-默认

self.tableView.mj_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.mj_header = [MJRefreshNormalHeader headerWithRefreshingTarget:self refreshingAction:@selector(loadNewData)];

// Enter the refresh status immediately
[self.tableView.mj_header beginRefreshing];

(下拉刷新01-普通)

下拉刷新 02-动画图片

// 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;

(下拉刷新02-动画图片)

下拉刷新 03-隐藏时间

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

(下拉刷新03-隐藏时间)

下拉刷新 04-隐藏状态和时间

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

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

(下拉刷新04-隐藏状态和时间0)

下拉刷新 05-DIY 标题

// 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];

(下拉刷新05-自定义文字)

下拉刷新 06-DIY 刷新控制

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

(下拉刷新06-自定义刷新控件)

下拉刷新 01-默认

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)];

(上拉刷新01-默认)

下拉刷新 02-动画图像

// 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;

(上拉刷新02-动画图片)

下拉刷新 03-隐藏刷新状态标题

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

(上拉刷新03-隐藏刷新状态的文字)

下拉刷新 04-全部已加载

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

(上拉刷新04-全部加载完毕)

拉动刷新 05-DIY 标题

// 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];

(上拉刷新05-自定义文字)

拉动刷新 06-加载后隐藏

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

(上拉刷新06-加载后隐藏)

拉动刷新 07-自动回拉01

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

(上拉刷新07-自动回弹的上拉01)

拉动刷新 08-自动回拉02

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;

(上拉刷新07-自动回弹的上拉02)

拉动刷新 09-DIY 刷新控制(自动刷新)

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

(上拉刷新09-自定义刷新控件(自动刷新))

拉动刷新 10-DIY 刷新控制(自动回拉)

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

(上拉刷新10-自定义刷新控件(自动回弹))

UICollectionView01-下拉刷新

// 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
}];

(UICollectionView01-上下拉刷新)

UIWebView01-下拉刷新

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

(UICollectionView01-上下拉刷新)

提醒

  • ARC
  • iOS>=6.0
  • iPhone \ iPad 任意屏幕

希望

  • 如果在使用过程中发现bug,希望您可以通过 Issues 联系我,谢谢或尝试下载此框架的最新代码以查看BUG是否已修复)
  • 如果在使用过程中发现功能不足,希望您可以通过 Issues 联系我,我很乐意为其添加更多有用功能,谢谢!
  • 如果想要为 MJRefresh 贡献代码,请发起 Pull Requests 给我
  • 如果您在您的开发应用程序中使用 MJRefresh,希望您可以去CocoaControls添加您应用程序的 iTunes 路径,我会安装您应用程序,并根据许多应用程序的使用情况,使之成为更好的设计并改进 MJRefresh,谢谢!
    • 步骤O1(微信只是一个例子,探索“您的应用程序名称itunes”) (步骤01)
    • 步骤O2 (步骤02)
    • 步骤O3 (步骤03)
    • 第4步 (step04)

寻求志同道合的小伙伴

  • 由于个人工作忙,没有太多时间去维护MJRefresh,在此向广大框架使用者表示歉意:😞
  • 现在正在寻找志同道合的小伙伴一起来维护这个框架,有兴趣的小伙伴可以发邮件给我,非常感谢😊
  • 如果一切顺利,我将开放框架维护权限(github、pod等)
  • 目前已经找到3位小伙伴(^-^)V