What is the correct way to handleTapGesture when i press on cell?
I have MediaItem, LocationItem, AudioItem and attributedText cells, for each type i should use different actions, can you give me a small example please
@Frace17 I recommend you to implement MessageCellDelegate. Then you can handle tap on all kind of cells.
Most of them inherit from MessageContentCell.swift so you can implement didTapMessage as example. Note that theses delegate methods will give you the cell as parameter: didTapMessage(in cell: MessageCollectionViewCell). So inside your method you just have to detect which kind of cell you have.
Here is an example:
// MARK: - MessageCellDelegate
extension ChatViewController: MessageCellDelegate {
func didTapMessage(in cell: MessageCollectionViewCell) {
if cell is LocationMessageCell {
}
if cell is TextMessageCell {
}
}
}
If you want to take a look at the implementation you can see an example here MessageKit
@JulienKode I understand that i need to use didTapMessage(in cell: MessageCollectionViewCell) function, but i don't know how correctly get messageKind from gesture in handleTapGesture(_ gesture: UIGestureRecognizer) function. If its not too much trouble, can you give me small code example
@Frace17 Have you try something like that ?
// MARK: - MessageCellDelegate
extension ChatViewController: MessageCellDelegate {
func didTapMessage(in cell: MessageCollectionViewCell) {
if cell is LocationMessageCell {
}
if cell is TextMessageCell {
}
}
}
@JulienKode Great thank you!!! For help and fast response! <3
@Frace17 No problem 馃槉
Don't know if it's the best way to do it. May be @nathantannar4 and @SD10 have a better way to do it