1

I am using JSQMessagesViewController but am getting a crash when trying to start a chat. I suspect it has something to do with the ChatViewContoller. Does anyone know why?

// MARK: - UICollectionView flow layout

override func collectionView(collectionView: JSQMessagesCollectionView!, layout collectionViewLayout: JSQMessagesCollectionViewFlowLayout!, heightForCellTopLabelAtIndexPath indexPath: NSIndexPath!) -> CGFloat {
    if indexPath.item % 3 == 0 {
        return kJSQMessagesCollectionViewCellLabelHeightDefault
    }
    return 0
}

override func collectionView(collectionView: JSQMessagesCollectionView!, layout collectionViewLayout: JSQMessagesCollectionViewFlowLayout!, heightForMessageBubbleTopLabelAtIndexPath indexPath: NSIndexPath!) -> CGFloat {
    let message = self.messages[indexPath.item]
    if message.senderId == self.senderId {
        return 0
    }

    if indexPath.item - 1 > 0 {
        let previousMessage = self.messages[indexPath.item - 1]
        if previousMessage.senderId == message.senderId {
            return 0
        }
    }

    return kJSQMessagesCollectionViewCellLabelHeightDefault
}

override func collectionView(collectionView: JSQMessagesCollectionView!, layout collectionViewLayout: JSQMessagesCollectionViewFlowLayout!, heightForCellBottomLabelAtIndexPath indexPath: NSIndexPath!) -> CGFloat {
    return 0
}
Alexyesiam
  • 79
  • 8

0 Answers0