Prioritize the double-tap-to-zoom gesture over other double-tap gestures
This commit is contained in:
parent
e16185fa71
commit
967b7e5b53
|
@ -70,6 +70,8 @@ extension MediaPreviewImageView {
|
||||||
addSubview(imageView)
|
addSubview(imageView)
|
||||||
|
|
||||||
doubleTapGestureRecognizer.addTarget(self, action: #selector(MediaPreviewImageView.doubleTapGestureRecognizerHandler(_:)))
|
doubleTapGestureRecognizer.addTarget(self, action: #selector(MediaPreviewImageView.doubleTapGestureRecognizerHandler(_:)))
|
||||||
|
doubleTapGestureRecognizer.delegate = self
|
||||||
|
|
||||||
imageView.addGestureRecognizer(doubleTapGestureRecognizer)
|
imageView.addGestureRecognizer(doubleTapGestureRecognizer)
|
||||||
if #available(iOS 16.0, *) {
|
if #available(iOS 16.0, *) {
|
||||||
imageView.addInteraction(liveTextInteraction)
|
imageView.addInteraction(liveTextInteraction)
|
||||||
|
@ -113,6 +115,21 @@ extension MediaPreviewImageView {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extension MediaPreviewImageView: UIGestureRecognizerDelegate {
|
||||||
|
func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldBeRequiredToFailBy otherGestureRecognizer: UIGestureRecognizer) -> Bool {
|
||||||
|
guard gestureRecognizer == doubleTapGestureRecognizer else { return false }
|
||||||
|
// block double-tap to select text gesture
|
||||||
|
// but only if the Live Text button is toggled off
|
||||||
|
if let gr = otherGestureRecognizer as? UITapGestureRecognizer,
|
||||||
|
gr.numberOfTapsRequired == 2,
|
||||||
|
#available(iOS 16, *),
|
||||||
|
!liveTextInteraction.selectableItemsHighlighted {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
extension MediaPreviewImageView {
|
extension MediaPreviewImageView {
|
||||||
|
|
||||||
func setup(image: UIImage, container: UIView, forceUpdate: Bool = false) {
|
func setup(image: UIImage, container: UIView, forceUpdate: Bool = false) {
|
||||||
|
|
Loading…
Reference in New Issue