使用 JSQMessagesViewController 时 UI 不会出现

When Using JSQMessagesViewController the UI does not appear

我正在尝试实现 JSQMessagesViewController,并且我正在遵循 Ray Wenderlich 教程 (https://www.raywenderlich.com/122148/firebase-tutorial-real-time-chat),但是 UI 没有出现在我的视图控制器上,它只是空白。 这是我的 pod 文件。

source 'https://github.com/CocoaPods/Specs.git'
use_frameworks!
target "Sell Goods" do
    pod 'Firebase'
    pod 'Firebase/Storage'
    pod 'Firebase/Database'
    pod 'Google/SignIn'
    pod 'JSQMessagesViewController'
end

我试过使用桥接接头,但没有用,我按照教程一步一步来。

转到 ChatViewController

override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
    guard let editingVC = segue.destinationViewController as? ChatsViewController
        else {
            preconditionFailure("Bad")
        }
    editingVC.senderId = userID
    editingVC.senderDisplayName = userName
}    

ChatViewController

import Firebase
import JSQMessagesViewController

class ChatsViewController: JSQMessagesViewController {
var messages = [JSQMessage]()
var outgoingBubbleImageView: JSQMessagesBubbleImage!
var incomingBubbleImageView: JSQMessagesBubbleImage!
override func viewDidLoad() {
    title = "ChatChat"
    setupBubbles()
    //collectionView!.collectionViewLayout.incomingAvatarViewSize = CGSizeZero
    //collectionView!.collectionViewLayout.outgoingAvatarViewSize = CGSizeZero

    // Do any additional setup after loading the view.
}

override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
    // Dispose of any resources that can be recreated.
}

override func viewDidAppear(animated: Bool) {
    resetScreen = true
}
private func setupBubbles() {
    let factory = JSQMessagesBubbleImageFactory()
    outgoingBubbleImageView = factory.outgoingMessagesBubbleImageWithColor(
        UIColor.jsq_messageBubbleBlueColor())
    incomingBubbleImageView = factory.incomingMessagesBubbleImageWithColor(
        UIColor.jsq_messageBubbleLightGrayColor())
}
override func collectionView(collectionView: JSQMessagesCollectionView!,
                             messageBubbleImageDataForItemAtIndexPath indexPath: NSIndexPath!) -> JSQMessageBubbleImageDataSource! {
    let message = messages[indexPath.item]
    if message.senderId == senderId {
        return outgoingBubbleImageView
    } else {
        return incomingBubbleImageView
    }
}

override func collectionView(collectionView: JSQMessagesCollectionView!,
                             messageDataForItemAtIndexPath indexPath: NSIndexPath!) -> JSQMessageData! {
    return messages[indexPath.item]
}

override func collectionView(collectionView: UICollectionView,
                             numberOfItemsInSection section: Int) -> Int {
    return messages.count
}
override func collectionView(collectionView: JSQMessagesCollectionView!,
                             avatarImageDataForItemAtIndexPath indexPath: NSIndexPath!) -> JSQMessageAvatarImageDataSource! {
    return nil
}

}

您必须致电 super.viewDidLoad & super.viewDidDisappear