From c171eb40a2ffd2dae22a770bfae0252bbca0d7a1 Mon Sep 17 00:00:00 2001 From: willbin Date: Tue, 5 May 2015 21:54:08 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8A=8A=20setupDidReceiveTypedMessageCompleti?= =?UTF-8?q?on=20=E6=94=BE=E5=88=B0=20viewDidAppear=20=E4=B8=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Pages/IM/LeanChatMessageTableViewController.m | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Example/MessageDisplayKitLeanchatExample/MessageDisplayKitLeanchatExample/Sections/Pages/IM/LeanChatMessageTableViewController.m b/Example/MessageDisplayKitLeanchatExample/MessageDisplayKitLeanchatExample/Sections/Pages/IM/LeanChatMessageTableViewController.m index 44ffa5c..f5a8f89 100644 --- a/Example/MessageDisplayKitLeanchatExample/MessageDisplayKitLeanchatExample/Sections/Pages/IM/LeanChatMessageTableViewController.m +++ b/Example/MessageDisplayKitLeanchatExample/MessageDisplayKitLeanchatExample/Sections/Pages/IM/LeanChatMessageTableViewController.m @@ -120,7 +120,15 @@ - (void)viewDidLoad }]; } }]; +} + +// 这里也要把 setupDidReceiveTypedMessageCompletion 放到 viewDidAppear 中 +// 不然, 就会冲突, 导致不能实时接收到对方的消息 +- (void)viewDidAppear:(BOOL)animated +{ + [super viewDidAppear:animated]; + WEAKSELF [[LeanChatManager manager] setupDidReceiveTypedMessageCompletion:^(AVIMConversation *conversation, AVIMTypedMessage *message) { // 富文本信息 if([conversation.conversationId isEqualToString:self.conversation.conversationId]){ @@ -129,6 +137,11 @@ - (void)viewDidLoad }]; } +- (void)viewDidDisappear:(BOOL)animated { + [super viewDidDisappear:animated]; + [[LeanChatManager manager] setupDidReceiveTypedMessageCompletion:nil]; +} + - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning];