MJRefresh
#import "MainTableViewController.h"
#import "MJRefresh.h"
#import "HUDViewController.h"
@interface MainTableViewController ()
@property(nonatomic,strong)NSMutableArray * dataArray;
@end
@implementation MainTableViewController
- (void)viewDidLoad {
[super viewDidLoad];
_dataArray=[NSMutableArray arrayWithObjects:@"1",@"2",@"3",@"4",@"5",@"6",@"7",@"8", nil];
[self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"cell"];
[self.tableView reloadData];
// 添加刷header
MJRefreshNormalHeader * herder =[MJRefreshNormalHeader headerWithRefreshingBlock:^{
[self requestData];
}];
self.tableView.mj_header=herder;
[herder setTitle:@"正在加载中。。。" forState:MJRefreshStateRefreshing];
// 添加footer
self.tableView.mj_footer=[MJRefreshAutoNormalFooter footerWithRefreshingBlock:^{
[self requestData];
[self loadData];
}];
}
-(void)requestData{
NSLog(@"请求数据");
// 数据请求完成,停止刷新,重新刷新表格
[self.tableView.mj_header endRefreshing];
}
-(void)loadData{
NSLog(@"请求数据");
[self.tableView.mj_footer endRefreshing];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
#warning Incomplete implementation, return the number of sections
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
#warning Incomplete implementation, return the number of rows
return _dataArray.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell" forIndexPath:indexPath];
if (!cell) {
cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"cell"];
}
cell.textLabel.text=[_dataArray objectAtIndex:indexPath.row];
return cell;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
HUDViewController *hud =[[HUDViewController alloc]init];
[self presentViewController:hud animated:YES completion:^{
}];
}
小菊花控件
#import "HUDViewController.h"
#import "MBProgressHUD.h"
@interface HUDViewController ()
@end
@implementation HUDViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.view.backgroundColor=[UIColor whiteColor];
// 展示小菊花
MBProgressHUD *HUD =[MBProgressHUD showHUDAddedTo:self.view animated:YES];
HUD.label.text=@"三哥的菊花在转。。。。";
}