as my questions already says: I am currently implementing the JSQMessagesViewController component in Xamarin.iOS and everything works fine for now, but for some reason I can not find the heightForCellTopLabelAtIndexPath method as described at this link . All the other methods are visible to me, even the one that returns the attributed text for the top cell label.
Thanks for the help!
Wow I did not even know that you could use this library in Xamarin apps but also I don't do anything in Xamarin but that is super cool. Well as per your question. I was not able to see that method either so maybe the documentation is off but to use:
override func collectionView(_ collectionView: JSQMessagesCollectionView!, layout collectionViewLayout: JSQMessagesCollectionViewFlowLayout!, heightForMessageBubbleTopLabelAt indexPath: IndexPath!) -> CGFloat {
return firstMessageInSet(indexOfMessage: indexPath) ? 0 : kJSQMessagesCollectionViewCellLabelHeightDefault
}
The only difference is that it is referencing the messageBubbleTopLabel
and not the CellTopLabel
per say. I think that is the correct method to use.
In the screen shot provided I show how this effects the look of the messages. The first message has the size set to kJSQMessagesCollectionViewCellLabelHeightDefault
and the message fallowing it has it set to 0
So if that is what you are trying to achieve then this is the method for you. 🤓 if not, let me know and I will see if there is something else that we can do.
Keep up the good work. 🖖🏽
I think you are looking for GetMessageBubbleTopLabelHeight !
I'm not aware of any Xamarin oriented doc for this lib, but I'll gladly give you an example usage =)
This is how i used the function :
public override nfloat GetMessageBubbleTopLabelHeight (MessagesCollectionView collectionView, MessagesCollectionViewFlowLayout collectionViewLayout, NSIndexPath indexPath)
{
Message message = Messages [indexPath.Row];
if (message.SenderId == Sender.UserId.ToString())
return 0.0f;
if (indexPath.Row - 1 >= 0) {
Message previousMessage = Messages [indexPath.Row - 1];
if (previousMessage.SenderId == message.SenderId)
return 0.0f;
}
return 20.0f;
}
In the end I just used the GetCellTopLabelAttributedText and modified it to fit my use case. In other words I central aligned the text, deleted the contentInset and changed the font. I gave up looking for the method that was missing
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.