记录下自己总结的刷新方法,免得忘记了....
-(void)getDataWithHead:(BOOL)isHead{
if (isHead) {
page = 1;
}else{
if (page < 2) {
page = 2;
}
}
[GPAFNetworking3 get:[NSString stringWithFormat:@"%@?articleId=%ld&source=toyohuApp&site=QA&page=%ld",GetCommunityComment,(long)_caId,(long)page] progress:^(NSProgress * _Nonnull progress) {
} success:^(id _Nullable responseObject) {
if ([[responseObject objectForKey:@"code"] integerValue] != 1) {
SHOW_ERROR
}else{
MyCommentMyComment*base = [[MyCommentMyComment alloc]initWithDictionary:responseObject];
if (base.msg.comment.count){
if (isHead) {
[QAArray removeAllObjects];
}else{
page ++;
}
[QAArray addObjectsFromArray: base.msg.comment];
}else{
[(MJRefreshAutoGifFooter *)myTableView.mj_footer setTitle:@"空空如也" forState:MJRefreshStateIdle];
}
[myTableView reloadData];
}
if (isHead) {
[myTableView.mj_header endRefreshing];
}else{
dispatch_async(dispatch_get_main_queue(), ^{
[myTableView.mj_footer endRefreshing];
});
}
} failure:^(NSString * _Nonnull errorLD) {
SHOW_NTERROR
if (isHead) {
[myTableView.mj_header endRefreshing];
}else{
dispatch_async(dispatch_get_main_queue(), ^{
[myTableView.mj_footer endRefreshing];
});
}
}];
}
使用:
-(void)LoadNewData
{
[self getDataWithHead:YES];
}
-(void)loadMoreData
{
[self getDataWithHead:NO];
}
网友评论