-1
msgStr= [dict valueForKey:@"enquiry_body"];
NSDictionary *dictionay = [dict objectForKey:@"createdBy"];
idStr= [dictionay valueForKey:@"_id"];
JSQMessage *newMessage= nil;
newMessage= [JSQMessage messageWithSenderId:idStr displayName:@"" text:msgStr];

[self.demoData.messages addObject:newMessage];

Here is my code msgStr contains message from web service idstr is user id who previously send this message. The issue is that the messages sent from the sender get aligned to the left. Although there is no problem with the receiver, the messages received are aligned to left as they should be.The only issue is with those sent by the sender.

Please refer screenshot given below.

enter image description here

Larme
  • 24,190
  • 6
  • 51
  • 81
himanshu
  • 25
  • 1
  • 7

1 Answers1

0

I assume you are missing this function. If you provide more detail about what you are doing we may be able to help you further.

override func collectionView(collectionView: JSQMessagesCollectionView, messageBubbleImageDataForItemAtIndexPath indexPath: NSIndexPath) -> JSQMessageBubbleImageDataSource {

    return messages[indexPath.item].senderId == self.senderId() ? outgoingBubble : incomingBubble
}
Dan Leonard
  • 3,325
  • 1
  • 20
  • 32