Today I met a very strange problem, integrated cloud chat, to get the number of unread group, I wrote a notice to update the number of messages in the TableView cell, but the number of messages changed very slowly, and sometimes not update I was updating a cell
[Self.tableview Reloadrowsatindexpaths:@[[nsindexpath indexpathforrow:i insection:0]] WithRowAnimation: Uitableviewrowanimationautomatic]; At the time of testing found that the cell DrawRect method does not execute, if it is direct reloaddata, there is no problem,
Found a sentence in the log this application is modifying the AutoLayout engine from a background thread after the engine was a, below is my pass Know the method so that it's OK to refresh in the main thread,
-(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
}
}
}
}