国产探花免费观看_亚洲丰满少妇自慰呻吟_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;

            }

        }

    }

    

}


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 桑日县| 五常市| 湖口县| 许昌县| 衡山县| 义乌市| 昌宁县| 日照市| 红原县| 育儿| 夏津县| 长丰县| 定日县| 白玉县| 虞城县| 额济纳旗| 余江县| 扎囊县| 延吉市| 游戏| 古蔺县| 新源县| 泰来县| 庆元县| 苍溪县| 布拖县| 嵩明县| 阿瓦提县| 宝山区| 车险| 彰化市| 山丹县| 望谟县| 宣城市| 左贡县| 苏尼特右旗| 和林格尔县| 全州县| 喜德县| 文登市| 宿迁市|