Messagekit: How to create a custom cell

Created on 30 Jul 2018  路  3Comments  路  Source: MessageKit/MessageKit

Hey guys, I have a question that is blocking me for quite a while. I've created a custom MessageContentCell with a Xib file, and I am trying to use it by setting the type of my message to custom(Any?). Following the instructions on the file I need to implement these 2 methods:

///   - `collectionView(_:cellForItemAt indexPath: IndexPath) -> UICollectionViewCell`
///   - `cellSizeCalculatorForItem(at indexPath: IndexPath) -> CellSizeCalculator`

The first one cellForItemAt: goes without a problem, but the second one I don't really know where to put. I've created a subclass of the MessageSizeCalculator and tried to use in many parts of the viewController, but I am completely lost.

Could someone instruct me?

  • Version of MessageKit: 1.0.0
  • Version of iOS: 11.4
  • Version of Swift: 4.1

Most helpful comment

Hey @svmadiraju thanks a lot for the link, it works great!

All 3 comments

Hey there,
I very recently figured out how to make custom cells and have been working with them for a little bit. I simply followed the steps outlined in #686 (wildseansy's comment) and it worked like a charm. I suggest you try following that method, feel free to hit me up if you have trouble with it.

Thanks a lot @svmadiraju I will try it and update the ticket right after

Hey @svmadiraju thanks a lot for the link, it works great!

Was this page helpful?
0 / 5 - 0 ratings