美文网首页
iOS刷新框架MJRefresh的使用

iOS刷新框架MJRefresh的使用

作者: Bryan5137 | 来源:发表于2016-05-05 11:58 被阅读498次

MJRefresh的使用

- (void)viewWillAppear:(BOOL)animated

{

[superviewWillAppear: animated];

[self.tableView.header beginRefreshing];

}

- (void)viewDidLoad {

[superviewDidLoad];

self.tableView= [[UITableView alloc]initWithFrame:self.view.bounds];

self.tableView.delegate=self;

self.tableView.dataSource=self;

[self.view addSubview:_tableView];

MJRefreshNormalHeader* header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{

[self performSelector:@selector(delayMethod)withObject:nil afterDelay:5.0f];

}];

[header setTitle:@"闲置中的状态"forState:MJRefreshStateIdle];

[header setTitle:@"松开就可以刷新了"forState:MJRefreshStatePulling];

[header setTitle:@"正在刷新中"forState:MJRefreshStateRefreshing];

self.tableView.header= header;

self.tableView.footer= [MJRefreshBackNormalFooter footerWithRefreshingBlock:^{

[self performSelector:@selector(delayMethod)withObject:nil afterDelay:5.0f];

}];

}

-(void)delayMethod{

[self.endRefresh];

}

-(void)endRefresh{

[self.tableView.header endRefreshing];

[self.tableView.footer endRefreshing];

}

# pragma mark - tabelView代理方法.

- (NSInteger)tableView:(UITableView*)tableView numberOfRowsInSection:(NSInteger)section

{

return10;

}

- (UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath

{

NSString* cellReuseIdentifier =@"cell";

UITableViewCell* cell = [tableView dequeueReusableCellWithIdentifier: cellReuseIdentifier];

if(!cell) {

cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellReuseIdentifier];

}

cell.textLabel.text=@"hello";

return cell;

}

相关文章

网友评论

      本文标题:iOS刷新框架MJRefresh的使用

      本文链接:https://www.haomeiwen.com/subject/uhddrttx.html