Before ios7, the open source EGO library has been used. However, during use, it is found that the encapsulation is too complex and the coupling is strong, which is not conducive to integration into your own projects.
In addition, some original pull-down refreshes after ios7, and the loading control is not so outstanding. In addition to possible errors, it does not conform to the flat style.
Later, I found a Daniel uploaded an open source code on code4App. Just a few lines of code can be used to add a pull-down or pull-up refresh function to UITableView or CollectionView. You can customize text descriptions for up/down refresh.
Download the package and try it out. Mark.
The following is a record of your integration process. Of course, the demo provided by the author has already been detailed. This is just a record of your own implementation process.
1. Import the entire MJRefresh folder to the required project.
2. The MJRefresh. bundle ---> arrow@2x.png image in the folder can be replaced by itself, which will be displayed during the refresh process.
3. You can customize the displayed text content and color in the MJRefreshConst. h and MJRefreshConst. m files.
4. As long as your view can be rolled, You can integrate this control, such as UIScrollView, UITableView, and UICollectionView.
5. Add the following code as needed.
5.1 import header files
#import MJRefresh.h
5.2 compliance
@interface ViewController ()
5.3 add controls for your view
MJRefreshFooterView *footer = [MJRefreshFooterView footer]; footer.scrollView = myTableView; footer.delegate = self; MJRefreshHeaderView *header = [MJRefreshHeaderView header]; header.scrollView = myTableView; header.delegate = self;
5.4 proxy method implementation
# Pragma mark-proxy method for refreshing controls # pragma mark begins to enter the refresh status-(void) refreshViewBeginRefreshing :( MJRefreshBaseView *) refreshView {NSLog (---- starts to enter the refreshView status. class); // refresh the table UI after 2.2 seconds [self defined mselector: @ selector (doneWithView :) withObject: refreshView afterDelay: 2.0];} # refresh pragma mark-(void) refreshViewEndRefreshing :( MJRefreshBaseView *) refreshView {NSLog (@ ---- refresh finished, refreshView. class) ;}# pragma mark listens for changes to the refresh status-(void) refreshView :( MJRefreshBaseView *) refreshView stateChange :( MJRefreshState) state {switch (state) {case MJRefreshStateNormal: NSLog (@ % @ ---- switch to: normal status, refreshView. class); break; case MJRefreshStatePulling: NSLog (@ % @ ---- switch to: refresh status after releasing, refreshView. class); break; case MJRefreshStateRefreshing: NSLog (@%@---- switch to: Refreshing status, refreshView. class); break; default: break ;}# pragma mark refreshes the table and ends refreshing status-(void) doneWithView :( MJRefreshBaseView *) refreshView {// refresh the table [myTableView reloadData]; // (preferably called after refreshing the table) Call endRefreshing to end the refresh status [refreshView endRefreshing];}
6. You can call beginRefreshing to automatically enter the pull-down refresh status.
7. You can call endRefreshing to end the refresh status.
8. To prevent internal leakage, it is best to release the occupied memory in the Controller's dealloc.
-(Void) dealloc
{
[_ Header free];
[_ Footer free];
}
: