I have two UIGestureRecognizers for a view that recognizes both simultaneously. I’d like for the finish or cancellation of the primary gesture to kill the other gesture as well. So, is there a way to kill an active gesture, i.e. force the cancellation of an active gesture recognizer?
I have two UIGestureRecognizers for a view that recognizes both simultaneously. I’d like for
Share
Since you want to kill the secondary gesture only when the primary gesture has ended or cancelled, do this in the gesture handler of the primary gesture.
This seems to be the only way you can cancel a gesture.
You can use
requireGestureRecognizerToFail:to declare a dependency.This will kill the secondary gesture on successful identification of the primary gesture. There is no such tool provided if the primary gesture is cancelled. You can probably flip the
enabledflag of the secondary gesture toNOandYESin the gesture handler of the primary gesture onUIGestureRecognizerStateCancelledbut that doesn’t seem elegant.