.h文件
#import <UIKit/UIKit.h>
#import <MJRefresh.h>
typedef void(^refreshAction)(void);
@interface UITableView (AddRefresh)
/**
添加上拉下拉控件
*/
- (void)addRefreshForPullDown:(refreshAction)PullDown PullUp:(refreshAction)PullUp;
/**
添加下拉控件
*/
- (void)addRefreshForPullDown:(refreshAction)PullDown;
/**
添加上拉控件
*/
- (void)addRefreshForPullUp:(refreshAction)PullUp;
- (void)endRefresh;
- (void)NoMoreData;
- (void)MoreData;
@end
.m文件
#import "UITableView+AddRefresh.h"
@implementation UITableView (AddRefresh)
- (void) addRefreshForPullDown:(refreshAction)PullDown PullUp:(refreshAction)PullUp{
[self addRefreshForPullDown:PullDown];
[self addRefreshForPullUp:PullUp];
}
- (void)addRefreshForPullDown:(refreshAction)PullDown{
MJRefreshNormalHeader *header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
PullDown();
}];
header.lastUpdatedTimeLabel.hidden = YES;
self.mj_header = header;
}
- (void)addRefreshForPullUp:(refreshAction)PullUp{
MJRefreshAutoNormalFooter *footer = [MJRefreshAutoNormalFooter footerWithRefreshingBlock:^{
PullUp();
}];
self.mj_footer =footer;
}
- (void)endRefresh{
[self.mj_header endRefreshing];
[self.mj_footer endRefreshing];
}
- (void)NoMoreData{
[self.mj_header endRefreshing];
[self.mj_footer endRefreshingWithNoMoreData];
}
- (void)MoreData{
[self.mj_footer resetNoMoreData];
}
@end