diff --git a/Sources/MessageCollectionViewCell.swift b/Sources/MessageCollectionViewCell.swift index f2307b44..5bf2bff5 100644 --- a/Sources/MessageCollectionViewCell.swift +++ b/Sources/MessageCollectionViewCell.swift @@ -204,6 +204,7 @@ open class MessageCollectionViewCell: UICollectionViewCell { let messageTapGesture = UITapGestureRecognizer(target: self, action: #selector(didTapMessage)) messageContainerView.addGestureRecognizer(messageTapGesture) + messageTapGesture.delegate = messageLabel let topLabelTapGesture = UITapGestureRecognizer(target: self, action: #selector(didTapTopLabel)) cellTopLabel.addGestureRecognizer(topLabelTapGesture) diff --git a/Sources/MessageLabel.swift b/Sources/MessageLabel.swift index 500f2ac5..ca4fbeee 100644 --- a/Sources/MessageLabel.swift +++ b/Sources/MessageLabel.swift @@ -193,16 +193,19 @@ open class MessageLabel: UILabel, UIGestureRecognizerDelegate { public func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldReceive touch: UITouch) -> Bool { let touchLocation = touch.location(in: self) - guard let index = stringIndex(at: touchLocation) else { return false } - for (_, ranges) in rangesForDetectors { - for nsRange in ranges { - guard let range = nsRange.toRange() else { return false } - if range.contains(index) { return true } + if let index = stringIndex(at: touchLocation) { + for (_, ranges) in rangesForDetectors { + for nsRange in ranges { + guard let range = nsRange.toRange() else { return false } + if range.contains(index) { + return gestureRecognizer.view == self + } + } } } - return false + return gestureRecognizer.view != self }