国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 系統 > iOS > 正文

ios NSNotificationCenter接受通知不能操作UI線程

2019-11-06 09:39:44
字體:
來源:轉載
供稿:網友
今天遇到了一個很奇怪的問題,集成融云聊天,,獲取群組未讀消息數量的時候,我寫了一個通知,再通知中更新tableview  Cell中的消息數量,但是消息數量改變的很慢,而且有時候不更新  我是更新某一個cell  

                        [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;

            }

        }

    }

    

}


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 喜德县| 马尔康县| 岫岩| 哈巴河县| 门源| 永胜县| 许昌县| 土默特右旗| 甘孜县| 莆田市| 灵台县| 金平| 丰宁| 安塞县| 乳源| 遂平县| 孝义市| 雷山县| 柏乡县| 灵川县| 静海县| 密山市| 凌源市| 南召县| 象州县| 淮滨县| 吴江市| 崇义县| 安化县| 繁峙县| 霍山县| 巴林右旗| 神池县| 仪征市| 湾仔区| 襄城县| 营山县| 天柱县| 商丘市| 峨山| 连州市|