下面的函数调用生成线程1: EXC_BREAKPOINT (code=1,subcode=0x189d35a80)。
func showChatView(message: ChatMessage) {
DispatchQueue.main.async {
if self.chatViewController == nil {
let mainStoryboard : UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
self.chatViewController = mainStoryboard.instantiateViewController(withIdentifier: "VAChatViewController") as? VAChatViewController
self.chatViewController?.delegate = self;
}
self.chatViewController?.messages += [message]
self.navigationController?.pushViewController(self.chatViewController!, animated: true, completion: {
let buttonMessage = self.chatViewController?.messages.last
let hasButtons = buttonMessage?.hasButtons
if hasButtons! {
let vaButtonModel = ChatMessage(buttons: buttonMessage?.buttons)
self.chatViewController?.addNewMessage(vaButtonModel)
}
})
}
}
还有一件事- VAChatViewController实现了collectionView来显示传入的聊天事件,这是对字符串消息"xyz“的响应。在collectionView委托中,我得到了arraycount >0,但它没有在numberOfItems之后调用collectionView: cellForItemAt,并使用SIGABRT崩溃,然后是上面的崩溃。有什么想法吗?
发布于 2017-09-27 01:23:45
愚蠢的错误。我多次调用showChatView:原因是我只为ChatViewController创建了一个对象,但是我忘了检查pushViewController。这就是崩溃的原因。谢谢
https://stackoverflow.com/questions/46416298
复制相似问题