[英]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.viewDidLoad
和super.viewDidDisappear
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.