I was trying to implement MessageKit (Replacement of JSQMessagesViewController) for chat feature, in my iOS swift application. I have followed this raywenderlich tutorial. I installed using Pods and followed this tutorial step by step. My messages are showing. According to this tutorial, for hiding the user avatar, i set my viewController to be delegate of messagesLayoutDelegate
and messagesDisplayDelegate
.
//Inside view did load, i set the delegates, along with data source
messagesCollectionView.messagesDataSource = self
messagesCollectionView.messagesLayoutDelegate = self
messagesCollectionView.messagesDisplayDelegate = self
However, the delegate functions of MessagesLayoutDelegate
are not being called.
I wanted to hide user avatar so i adopted the protocols in my viewController
extension ChatLogVC_MessageKit: MessagesLayoutDelegate {
func avatarSize(for message: MessageType, at indexPath: IndexPath,
in messagesCollectionView: MessagesCollectionView) -> CGSize {
//return zero size for hiding avatar, but this function is not being called.
return .zero
}
func footerViewSize(for message: MessageType, at indexPath: IndexPath,
in messagesCollectionView: MessagesCollectionView) -> CGSize {
//also not being called
return CGSize(width: 0, height: 8)
}
}
I have set break points inside these functions but the break points never hit. Morever, the shouldDisplayHeader
function of MessagesDisplayDelegate
is also not being called
Any help would be much appreciated
Note: I have tested it on simulator only.