0

I'm using JSQMessagesViewController and I write my custom photo and voice MediaItems which inheritance JSQMediaItem, and the mediaView of these two message types are different. Everything goes fine when sending/receiving these two kind of messages, but when I use a loop to load some historical messages, it appears incorrectly.

screenShot1

It seems that all the mediaMessage reused the first mediaMessage's cell size. But when I send photo/voice messages then, the newly send message appears correctly.

screenShot2

my cellForItemAtIndexPath method is as follow:

override func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
    let cell = super.collectionView(collectionView, cellForItemAtIndexPath: indexPath)
    return cell
}

The message loading code:

for msg in msgs {
    let jsqMessage = self.genJSQMessage(msg)
    self.messages.append(jsqMessage)
    self.finishSendingMessageAnimated(true)
}

I am really confused, any advice and suggestions will be greatly appreciated!

Cong Tran
  • 1,448
  • 14
  • 30

1 Answers1

0

I figured out that I did not override mediaHash() function in JSQMediaItem.