CollectionView在pushViewController上生成SIGABRT

时间:2017-09-26 01:03:20

标签: ios swift3 uicollectionview uicollectionviewlayout

在函数调用下面生成线程1:EXC_BREAKPOINT(代码= 1,子代码= 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委托中,我得到了数组[count]> 0但是它没有在numberOfItems之后调用collectionView:cellForItemAt并且使用SIGABRT崩溃,然后是上面的崩溃。有什么想法吗?

1 个答案:

答案 0 :(得分:0)

愚蠢的错误。我正在调用showChatView:多次因为我创建了一个ChatViewController的单个对象,但我忘记将pushViewController置于任何检查之下。而且,这就是崩溃的原因。感谢