简体   繁体   English

使用JSQMessagesViewController时,UI不会出现

[英]When Using JSQMessagesViewController the UI does not appear

I am trying to implement JSQMessagesViewController, and I am following the Ray Wenderlich tutorial( https://www.raywenderlich.com/122148/firebase-tutorial-real-time-chat ), but the UI is not appearing on my view controller, it is just blank. 我正在尝试实现JSQMessagesViewController,并且正在遵循Ray Wenderlich教程( https://www.raywenderlich.com/122148/firebase-tutorial-real-time-chat ),但是UI没有出现在我的视图控制器上,它只是空白。 This is my pod file. 这是我的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

I have tried using a bridging header but that did not work, and I followed the tutorial step by step. 我尝试使用桥接标头,但是那没有用,我一步一步地遵循了本教程。

Segue to ChatViewController Segue到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 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.viewDidLoadsuper.viewDidDisappear

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在UISplitviewCOntroller中将JSQMessagesViewController用作detailView时,KeyBoardToolBar只需要出现在DetailViewController中 - When using JSQMessagesViewController as detailView in UISplitviewCOntroller, KeyBoardToolBar needs to appear in DetailViewController only 为什么当我在JSQMessagesViewController中按下发送按钮时出现2条消息 - Why do 2 messages appear when I press the send button in JSQMessagesViewController 使用JSQMessagesViewController时出错 - Error using JSQMessagesViewController 使用 JSQMessagesViewController 的 NSInvalidArgumentException - NSInvalidArgumentException with using JSQMessagesViewController 如何使用JSQMessagesViewController发送图片? - How to send Pictures using JSQMessagesViewController? 将解析平台与JSQMessagesViewController Swift结合使用 - Using Parse Platform with JSQMessagesViewController Swift 在Parse.com中使用JSQMessagesViewController - Using JSQMessagesViewController with Parse.com 在JSQMessagesViewController中使用Right To Left语言时,气泡顶部和底部的文本不会反转 - Text at top and bottom of bubble doesn't invert side when using Right To Left langage in JSQMessagesViewController 使用Swift 3在JSQMessagesViewController中读取未读消息 - Read unread message in JSQMessagesViewController using Swift 3 如何使用JSQMessagesViewController显示消息详细信息 - how to show message details using JSQMessagesViewController
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM