一.最新版的MJRefresh
首先介绍M了个J的 最新版的MJRefresh
因为他的github里有详细介绍,话不多说上代码
二.EGOTableViewPullRefresh
- <span style="font-size:18px;">#import "ViewController.h"
- #import "PullTableView.h"
-
- @interface ViewController ()<PullTableViewDelegate,UITableViewDataSource,UITableViewDelegate>
- {
- PullTableView *_tableView;
- NSMutableArray *_arr;
- }
-
- @end
-
- @implementation ViewController
-
- - (void)viewDidLoad {
- [super viewDidLoad];
-
- self.view.backgroundColor = [UIColor magentaColor];
-
- _tableView = [[PullTableView alloc]initWithFrame:CGRectMake(0, 64, self.view.frame.size.width, self.view.frame.size.height-64)];
- _tableView.delegate = self;
- _tableView.dataSource = self;
- _tableView.pullDelegate = self;
-
- _arr = [NSMutableArray arrayWithObjects:@"111",@"222",@"333",@"444",@"555", nil nil];
-
-
-
-
- _tableView.pullBackgroundColor = [UIColor lightGrayColor];
-
- _tableView.pullTextColor = [UIColor purpleColor];
-
- _tableView.pullArrowImage = [UIImage imageNamed:@"tabBar_Found"];
-
-
-
-
-
-
-
-
-
-
- [self.view addSubview:_tableView];
-
- }
-
- - (void)didReceiveMemoryWarning {
- [super didReceiveMemoryWarning];
-
- }
-
-
-
- #pragma mark UITableViewDataSource
-
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
- {
- return _arr.count;
- }
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
- {
- static NSString *cellId = @"cellId";
- UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellId];
- if (!cell) {
- cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellId];
- }
- cell.textLabel.text = _arr[indexPath.row];
-
- return cell;
- }
-
- - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
- {
- [_arr removeObject:_arr[indexPath.row]];
- [_tableView reloadData];
- }
-
-
-
- #pragma mark PullTableViewDelegate
-
- -(void)pullTableViewDidTriggerLoadMore:(PullTableView *)pullTableView
- {
- NSLog(@"上拉加载");
-
- [self performSelector:@selector(addMore) withObject:nil afterDelay:3];
- }
- -(void)addMore
- {
- [_arr addObject:@"777"];
- [_tableView reloadData];
-
- _tableView.pullTableIsLoadingMore=NO;
- }
-
- -(void)pullTableViewDidTriggerRefresh:(PullTableView *)pullTableView
- {
- NSLog(@"下拉刷新");
-
- [self performSelector:@selector(refresh) withObject:nil afterDelay:3];
- }
- -(void)refresh
- {
- [_arr addObject:@"666"];
- [_tableView reloadData];
-
- _tableView.pullTableIsRefreshing=NO;
- }
-
-
- @end</span>
EGOTableViewPullRefresh github : https://github.com/enormego/EGOTableViewPullRefresh
MJRefresh github: https://github.com/CoderMJLee/MJRefresh
本文综合版Demo : http://download.csdn.net/detail/jackjia2015/9410080