[英]How to remove panGesture after touch in swift
I have a view that recognizes both a UIPanGesture and a single tap. 我有一个既可以识别UIPanGesture又可以单击的视图。 How do I disable the pan gesture once the view has been tapped?
点击视图后如何禁用平移手势? I have tried multiple ways but cannot seem to figure it out.
我尝试了多种方法,但似乎无法弄清楚。 Here is the last method I tried:
这是我尝试的最后一种方法:
func gestureRecognizer(singleTapRecognizer: UIGestureRecognizer?, shouldRequireFailureOfGestureRecognizer panGesture: UIPanGestureRecognizer?) -> Bool? {
print("in gesture recognizer")
if wasTapped == true {
return true
}
else {
return false
}
Thanks! 谢谢!
I think you're looking for something along the lines of 我认为您正在寻找符合以下条件的产品
panGesture.requireGestureRecognizerToFail(singleTapRecognizer)
Which would, preferably, be called just after you have created both of the gesture recognizers. 创建两个手势识别器后,最好立即调用该方法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.