Can any one let me know what exactly the below code line will do? I have referred Apples documentation but didn't get the exact picture about this,
[scrollview.panGestureRecognizer requireGestureRecognizerToFail:swipeRightGesture];
When user make a right swipe gesture then pan gesture will be failed (ignored).
An example,[_singleTap requireGestureRecognizerToFail:_doubleTap]
, when you want a single-tap gesture require that a double-tap gesture fail. Double-tap includes two single taps, so if no requireGestureRecognizerToFail
single-tap gesture delegate method may invoke twice.
So here, swipe gesture may trigger pan gesture, then will invoke panGestureRecognizer delegate method while you are swiping actually.
If add [panGestureRecognizer requireGestureRecognizerToFail:swipeRightGesture]
, once swipeRightGesture transitions to UIGestureRecognizerStateRecognized or UIGestureRecognizerStateBegan, panGestureRecognizer
transitions to UIGestureRecognizerStateFailed immediately.
And only swipeRightGesture haven't transited to above RecognizerStates, there is possible for panGestureRecognizer to respond, transited to UIGestureRecognizerStateBegan, and invoke panGestureRecognizer delegate method.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With