mirror of
https://github.com/MessageKit/MessageKit.git
synced 2026-02-06 19:03:19 +00:00
Fix conflicting gesture recognizers
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user