|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362 |
- 
- ## MJRefresh
- * An easy way to use pull-to-refresh
-
- ## Contents
- * Getting Started
- * [Features【Support what kinds of controls to refresh】](#Support what kinds of controls to refresh)
- * [Installation【How to use MJRefresh】](#How to use MJRefresh)
- * [Who's using【More than hundreds of Apps are using MJRefresh】](#>More than hundreds of Apps are using MJRefresh)
- * [Classes【The Class Structure Chart of MJRefresh】](#The Class Structure Chart of MJRefresh)
- * Comment API
- * [MJRefreshComponent.h](#MJRefreshComponent.h)
- * [MJRefreshHeader.h](#MJRefreshHeader.h)
- * [MJRefreshFooter.h](#MJRefreshFooter.h)
- * [MJRefreshAutoFooter.h](#MJRefreshAutoFooter.h)
- * Examples
- * [Reference](#Reference)
- * [The drop-down refresh 01-Default](#The drop-down refresh 01-Default)
- * [The drop-down refresh 02-Animation image](#The drop-down refresh 02-Animation image)
- * [The drop-down refresh 03-Hide the time](#The drop-down refresh 03-Hide the time)
- * [The drop-down refresh 04-Hide status and time](#The drop-down refresh 04-Hide status and time)
- * [The drop-down refresh 05-DIY title](#The drop-down refresh 05-DIY title)
- * [The drop-down refresh 06-DIY the control of refresh](#The drop-down refresh 06-DIY the control of refresh)
- * [The pull to refresh 01-Default](#The pull to refresh 01-Default)
- * [The pull to refresh 02-Animation image](#The pull to refresh 02-Animation image)
- * [The pull to refresh 03-Hide the title of refresh status](#The pull to refresh 03-Hide the title of refresh status)
- * [The pull to refresh 04-All loaded](#The pull to refresh 04-All loaded)
- * [The pull to refresh 05-DIY title](#The pull to refresh 05-DIY title)
- * [The pull to refresh 06-Hidden After loaded](#The pull to refresh 06-Hidden After loaded)
- * [The pull to refresh 07-Automatic back of the pull01](#上The pull to refresh 07-Automatic back of the pull01)
- * [The pull to refresh 08-Automatic back of the pull02](#The pull to refresh 08-Automatic back of the pull02)
- * [The pull to refresh 09-DIY the control of refresh(Automatic refresh)](#The pull to refresh 09-DIY the control of refresh(Automatic refresh))
- * [The pull to refresh 10-DIY the control of refresh(Automatic back)](#The pull to refresh 10-DIY the control of refresh(Automatic back))
- * [UICollectionView01-The pull and drop-down refresh](#UICollectionView01-The pull and drop-down refresh)
- * [UIWebView01-The drop-down refresh](#UIWebView01-The drop-down refresh)
- * [Hope](#Hope)
-
- ## <a id="Support what kinds of controls to refresh"></a>Support what kinds of controls to refresh
- * `UIScrollView`、`UITableView`、`UICollectionView`、`UIWebView`
-
- ## <a id="How to use MJRefresh"></a>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"`
-
- ```objc
- 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
- ```
-
- ## <a id=">More than hundreds of Apps are using MJRefresh"></a>More than hundreds of Apps are using MJRefresh
- <img src="http://images0.cnblogs.com/blog2015/497279/201506/141212365041650.png" width="200" height="300">
- * More information of App can focus on:[M了个J-博客园](http://www.cnblogs.com/mjios/p/4409853.html)
-
- ## <a id="The Class Structure Chart of MJRefresh"></a>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<br>
- <img src="http://images0.cnblogs.com/blog2015/497279/201506/141358159107893.png" width="30%" height="30%">
-
- ## <a id="MJRefreshComponent.h"></a>MJRefreshComponent.h
- ```objc
- /** 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
- ```
-
- ## <a id="MJRefreshHeader.h"></a>MJRefreshHeader.h
- ```objc
- @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
- ```
-
- ## <a id="MJRefreshFooter.h"></a>MJRefreshFooter.h
- ```objc
- @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
- ```
-
- ## <a id="MJRefreshAutoFooter.h"></a>MJRefreshAutoFooter.h
- ```objc
- @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
- ```
-
- ## <a id="Reference"></a>Reference
- ```objc
- * 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.
- ```
- <img src="http://images0.cnblogs.com/blog2015/497279/201506/141345470048120.png" width="30%" height="30%">
-
- ## <a id="The drop-down refresh 01-Default"></a>The drop-down refresh 01-Default
-
- ```objc
- 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];
- ```
- 
-
- ## <a id="The drop-down refresh 02-Animation image"></a>The drop-down refresh 02-Animation image
- ```objc
- // 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;
- ```
- 
-
- ## <a id="The drop-down refresh 03-Hide the time"></a>The drop-down refresh 03-Hide the time
- ```objc
- // Hide the time
- header.lastUpdatedTimeLabel.hidden = YES;
- ```
- 
-
- ## <a id="The drop-down refresh 04-Hide status and time"></a>The drop-down refresh 04-Hide status and time
- ```objc
- // Hide the time
- header.lastUpdatedTimeLabel.hidden = YES;
-
- // Hide the status
- header.stateLabel.hidden = YES;
- ```
- 
-
- ## <a id="The drop-down refresh 05-DIY title"></a>The drop-down refresh 05-DIY title
- ```objc
- // 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];
- ```
- 
-
- ## <a id="The drop-down refresh 06-DIY the control of refresh"></a>The drop-down refresh 06-DIY the control of refresh
- ```objc
- self.tableView.mj_header = [MJDIYHeader headerWithRefreshingTarget:self refreshingAction:@selector(loadNewData)];
- // Implementation reference to MJDIYHeader.h和MJDIYHeader.m
- ```
- 
-
- ## <a id="The pull to refresh 01-Default"></a>The pull to refresh 01-Default
- ```objc
- 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)];
- ```
- 
-
- ## <a id="The pull to refresh 02-Animation image"></a>The pull to refresh 02-Animation image
- ```objc
- // 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;
- ```
- 
-
- ## <a id="The pull to refresh 03-Hide the title of refresh status"></a>The pull to refresh 03-Hide the title of refresh status
- ```objc
- // Hide the title of refresh status
- footer.refreshingTitleHidden = YES;
- // If does have not above method,then use footer.stateLabel.hidden = YES;
- ```
- 
-
- ## <a id="The pull to refresh 04-All loaded"></a>The pull to refresh 04-All loaded
- ```objc
- //Become the status of NoMoreData
- [footer noticeNoMoreData];
- ```
- 
-
- ## <a id="The pull to refresh 05-DIY title"></a>The pull to refresh 05-DIY title
- ```objc
- // 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];
- ```
- 
-
- ## <a id="The pull to refresh 06-Hidden After loaded"></a>The pull to refresh 06-Hidden After loaded
- ```objc
- //Hidden current control of the pull to refresh
- self.tableView.mj_footer.hidden = YES;
- ```
- 
-
- ## <a id="The pull to refresh 07-Automatic back of the pull01"></a>The pull to refresh 07-Automatic back of the pull01
- ```objc
- self.tableView.mj_footer = [MJRefreshBackNormalFooter footerWithRefreshingTarget:self refreshingAction:@selector(loadMoreData)];
- ```
- 
-
- ## <a id="The pull to refresh 08-Automatic back of the pull02"></a>The pull to refresh 08-Automatic back of the pull02
- ```objc
- 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;
- ```
- 
-
- ## <a id="The pull to refresh 09-DIY the control of refresh(Automatic refresh)"></a>The pull to refresh 09-DIY the control of refresh(Automatic refresh)
- ```objc
- self.tableView.mj_footer = [MJDIYAutoFooter footerWithRefreshingTarget:self refreshingAction:@selector(loadMoreData)];
- // Implementation reference to MJDIYAutoFooter.h和MJDIYAutoFooter.m
- ```
- 
-
- ## <a id="The pull to refresh 10-DIY the control of refresh(Automatic back)"></a>The pull to refresh 10-DIY the control of refresh(Automatic back)
- ```objc
- self.tableView.mj_footer = [MJDIYBackFooter footerWithRefreshingTarget:self refreshingAction:@selector(loadMoreData)];
- // Implementation reference to MJDIYBackFooter.h和MJDIYBackFooter.m
- ```
- 
-
- ## <a id="UICollectionView01-The pull and drop-down refresh"></a>UICollectionView01-The pull and drop-down refresh
- ```objc
- // 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
- }];
- ```
- 
-
- ## <a id="UIWebView01-The drop-down refresh"></a>UIWebView01-The drop-down refresh
- ```objc
- //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
-
- ## <a id="Hope"></a>Hope
- * If you find bug when used,Hope you can Issues me,Thank you or try to download the latest code of this framework to see the BUG has been fixed or not)
- * If you find the function is not enough when used,Hope you can Issues me,I very much to add more useful function to this framework ,Thank you !
- * If you want to contribute code for MJRefresh,please Pull Requests me
- * If you use MJRefresh in your develop app,Hope you can go to[CocoaControls](https://www.cocoacontrols.com/controls/mjrefresh)to add the iTunes path
- of you app,I Will install your app,and according to the usage of many app,to be a better design and improve to MJRefresh,Thank you !
- * StepO1(WeChat is just an Example,Explore“Your app name itunes”)
- 
- * StepO2
- 
- * StepO3
- 
- * StepO4
- 
|