问题
I have a view that recognizes both a UIPanGesture and a single tap. 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!
回答1:
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.
来源:https://stackoverflow.com/questions/32274838/how-to-remove-pangesture-after-touch-in-swift