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.
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.
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!