ios - JsqMessageViewController View 仅显示单行文本

标签 ios swift jsqmessagesviewcontroller

我目前正在使用 JSQMessageViewController 并用 firebase 表中的数据填充它 - 我遵循了 Firebase 网站上可用的 Fire-chat 示例。一切正常,除了出于某种原因,单元格只显示多行文本的第一行,然后将其切断。

我几乎遵循了 https://github.com/firebase/ios-swift-chat-example 是什么

我的传入/传出气泡 View 在我的 viewdidload 中实例化

self.incomingBubble = JSQMessagesBubbleImageFactory().incomingMessagesBubbleImageWithColor(CHAT_GRAY_COLOR)

单元格由我的消息数组填充

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

然后还有很多必需的 JSQCollectionView 方法,包括:

override func collectionView(collectionView: JSQMessagesCollectionView!, messageBubbleImageDataForItemAtIndexPath indexPath: NSIndexPath!) -> JSQMessageBubbleImageDataSource! {
    let message = messages[indexPath.item]

    if message.senderId() == sender {
        return outgoingBubble
    }

    return incomingBubble

}

如果有人在此之前遇到过此问题,我将不胜感激任何帮助。同时我会继续搜索文档

最佳答案

检查您的消息对象。气泡的高度由 Message.Hash 决定,因此如果您创建了自己的继承自 JSQMessage 的消息对象,请确保将哈希设置为简单如

func messageHash() -> UInt { 返回 UInt(self.hash) }

但是如果你像普通的 I.E 一样实现你的消息

JSQMessage(senderId: AvatarIdCook, displayName: DisplayNameCook, text: "What is this Black Majic?")

那你应该不会有这个问题。让我知道是否有帮助👊

关于ios - JsqMessageViewController View 仅显示单行文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36880479/

相关文章:

ios - swift : Pass TableViewCell text to new ViewController's cell

ios - 具有正偏移量的 CenterXAnchor 不起作用?

ios - 如何创建具有多个字幕的表格单元格

ios - 收藏 View 作为自定义键盘不起作用

ios - 气泡图像箭头始终指向正确的方向。如何将绿色气泡的箭头方向更改为向左?

ios - 如何为约束更改设置动画?

cocoa-touch - 使用 Swift 子类化 SKShapeNode

ios - 如何在核心情节饼图中心添加图片和标题?

swift - 带有导航栏的 JSQMessagesViewController

ios - 加载远程图像破坏了 JSQMessagesAvatarImageFactory