[self.tableView reloadRowsAtIndexPaths:@[[NSIndexPath indexPathForRow: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 = [[notification object] objectForKey:@"message"];
if (message) {
for (NSInteger i=0; i<self.customerArray.count; i++) {
CustomerModel *model = self.customerArray[i];
if ([model.ChatRoomId isEqualToString:message.targetId]) {
model.unreadMsg = @([[RCIMClient sharedRCIMClient] getUnreadCount:ConversationType_GROUP targetId:message.targetId]);
dispatch_async(dispatch_get_main_queue(), ^{
NSArray *visiableCells = self.tableView.visibleCells;
HomeListCell *cell = [self.tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:i inSection:0]];
if ([visiableCells containsObject:cell]) {
[self.tableView reloadRowsAtIndexPaths:@[[NSIndexPath indexPathForRow:i inSection:0]] withRowAnimation:UITableViewRowAnimationAutomatic];
}
});
break;
}
}
}
}