1

i've a problem with the position of my JSQmessage bubble.

when i "send" it the position is good but when i change the view then come back the bubble is more at left than before. (if i send a new one all bubble come back to a good position).

can someone now what can happen?

bubble at wrong position

enter image description here

bubble at good position (after new send)

enter image description here

Badal Shah
  • 7,541
  • 2
  • 30
  • 65

2 Answers2

1

In your ViewDidLoad() this

viewDidLoad(){
    super.viewDidLoad()
    collectionView?.collectionViewLayout.incomingAvatarViewSize = .zero
    collectionView?.collectionViewLayout.outgoingAvatarViewSize = .zero
}

I also have this function but I would assume essentially the same thing.

override func collectionView(collectionView: JSQMessagesCollectionView!, avatarImageDataForItemAtIndexPath indexPath: NSIndexPath!) -> JSQMessageAvatarImageDataSource? {
    return nil
}
Dan Leonard
  • 3,325
  • 1
  • 20
  • 32
  • This partially worked for me. Whenever I re-open a conversation that has at least one message, sent/received message have a huge padding from the border of the screen. The are nearly positioned in the middle of the screen. – Omar Lahlou Feb 18 '16 at 09:08
0

Use this after you load your chat history:

 dispatch_async(dispatch_get_main_queue(), ^{
    [self.collectionView reloadData];
});

This code is in objective c but I am sure you can convert it to swift :)

Besat
  • 1,428
  • 13
  • 27