Open ChrisRockC opened 7 years ago
- (void)addNotificationObserver {
switch (self.type) {
case DiscoveryControllerTypeNews: {
//最新
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(callBackAndRefresh:) name:@"RefreshNewsWithIndex" object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(CallBackWithRefresh) name:JKJNotificationName_publishNewsSuccess object:nil];
break;
}
case DiscoveryControllerTypeFollow: {
//关注
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(callBackAndRefresh:) name:@"RefreshConcernNewsWithIndex" object:nil];
break;
}
default:
break;
}
}
//动态详情点赞评论完成刷新页面指定的一行
- (void)callBackAndRefresh:(NSNotification *)notice{
NSIndexPath *indexP = notice.userInfo[@"indexP"];
JKJNewsDetailModel *detailModel = notice.userInfo[@"newsModel"];
JKJDiscoveryNewestNewsModel *model = [self.dataList objectAtIndex:indexP.row];
model.praiseFlag = detailModel.praiseFlag;
model.commentList = detailModel.commentList;
model.viewsNum = detailModel.viewsNum;
model.likeNum = detailModel.likeNum;
model.newsCount = detailModel.newsCount;
JKJDiscoveryCell *cell = [self.tableView cellForRowAtIndexPath:indexP];
[cell configCellWithModel:model indexPath:indexP];
[self.tableView reloadRowsAtIndexPaths:@[indexP] withRowAnimation:UITableViewRowAnimationAutomatic];
}
- (void)CallBackWithRefresh {
[self.tableView.mj_header beginRefreshing];
}
- (void)dealloc{
[[NSNotificationCenter defaultCenter] removeObserver:self];
}