[self.tableViewreloadRowsAtIndexPaths:@[[NSIndexPathindexPathForRow:i inSection:0]]withRowAnimation:UITableViewRowAnimationAutomatic];在测试的时候发现,cell的drawRect方法不执行,如果是直接reloadData ,就没问题,,
在log中发现了一句 This application is modifying the autolayout engine from a background thread after the engine was a ,下面是我的通知方法,这样在main线程中刷新就没什么问题了,
- (void)receiveMessage:(NSNotification *)notification
{
RCMessage *message = [[notificationobject] objectForKey:@"message"];
if (message) {
for (NSInteger i=0; i<self.customerArray.count; i++) {
CustomerModel *model =self.customerArray[i];
if ([model.ChatRoomIdisEqualToString:message.targetId]) {
model.unreadMsg =@([[RCIMClientsharedRCIMClient] getUnreadCount:ConversationType_GROUPtargetId:message.targetId]);
dispatch_async(dispatch_get_main_queue(), ^{
NSArray *visiableCells =self.tableView.visibleCells;
HomeListCell *cell = [self.tableViewcellForRowAtIndexPath:[NSIndexPathindexPathForRow:i inSection:0]];
if ([visiableCellscontainsObject:cell]) {
[self.tableViewreloadRowsAtIndexPaths:@[[NSIndexPathindexPathForRow:i inSection:0]]withRowAnimation:UITableViewRowAnimationAutomatic];
}
});
break;
}
}
}
}
新闻热点
疑难解答