Messagekit: How to get indexPath for tapped message

Created on 11 Oct 2018  路  3Comments  路  Source: MessageKit/MessageKit


I have implemented MessageKit in my app. Now I need to get indexPath of message. I used following code:

func didTapMessage(in cell: MessageCollectionViewCell) {
        //Call Method to Show Action Picker
        guard let indexPath = messagesCollectionView.indexPath(for: cell) else { return }
        print(indexPath.row)

    }

But when I print this row number it is always returning 0 I am not getting where I am wrong.

question

Most helpful comment

Have you tried checking the section as well? I believe they use a combination of sections for each message and rows for different parts of the message (top label, main message, bottom label, etc)

All 3 comments

Have you tried checking the section as well? I believe they use a combination of sections for each message and rows for different parts of the message (top label, main message, bottom label, etc)

You can use indexPath.section

MessageKit is section based, meaning each cell is in it's own section (as others have pointed out above). You will need to use indexPath.section

Was this page helpful?
0 / 5 - 0 ratings

Related issues

nitrag picture nitrag  路  3Comments

JulienLevallois picture JulienLevallois  路  4Comments

pawankmrai picture pawankmrai  路  3Comments

yspreen picture yspreen  路  3Comments

NiklasWilson picture NiklasWilson  路  4Comments