赞
踩
1.导入第三方
MJRefresh
- (void)addHeaderRefresh{ /* 系统原生下拉刷新 UIRefreshControl * refresh = [[UIRefreshControl alloc]init]; [refresh addTarget:self action:@selector(refreshDown) forControlEvents:UIControlEventValueChanged]; [refresh setAttributedTitle:[[NSAttributedString alloc]initWithString:@"刷新..."]]; [self.tableView addSubview:refresh]; // [refresh endRefreshing];//停止刷新 */ /* 普通状态刷新 MJRefreshNormalHeader * header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{ NSLog(@"MJRefresh触发"); }]; self.tableView.header = header; */ MJRefreshGifHeader * header = [MJRefreshGifHeader headerWithRefreshingBlock:^{ //1、重置页数 // self.page = 1; //2、清空数据源 [self.dataSource removeAllObjects]; //3、重新发生网络请求 [self loadData]; }]; NSArray * imageArr = @[[UIImage imageNamed:@"common_loading_anne_0"],[UIImage imageNamed:@"common_loading_anne_1"]]; //正在刷新中的状态 [header setImages:imageArr forState:MJRefreshStateRefreshing]; //闲置状态 [header setImages:@[[UIImage imageNamed:@"common_loading_anne_0"]] forState:MJRefreshStateIdle]; //文字 [header setTitle:@"敌军还有30秒到达战场" forState:MJRefreshStateRefreshing]; self.tableView.mj_header = header; } - (void)refreshDown{ NSLog(@"下拉刷新触发"); } - (void)addFooterRefresh{ //上拉刷新 MJRefreshAutoGifFooter * footer = [MJRefreshAutoGifFooter footerWithRefreshingBlock:^{ //1、页数增加 //self.page++; //2、重新请求数据 [self loadData]; }]; NSArray * imageArr = @[[UIImage imageNamed:@"loading_teemo_1"],[UIImage imageNamed:@"loading_teemo_2"]]; [footer setImages:imageArr forState:MJRefreshStateRefreshing]; self.tableView.mj_footer = footer; }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。