vingrishOP•

In the doc Coordinating Multiple Gesture Recognizers, it says,

UIKit normally allows the recognition of only one gesture at a time on a single view. ... For example, in a view that contains both pan and swipe gesture recognizers, swipes are never recognized.

With that being said, there are also some exceptions. For example, in a view with two UITapGestureRecognizers, the actions of both will get fired.

There's the UIGestureRecognizerDelegate method gestureRecognizer(_:shouldRecognizeSimultaneouslyWith:) comes into play externally. But how can the system built-in gesture recognizers, such as UITapGestureRecognizer, decide internally whether or not to work with other recognizers? Or, is there any difference between continous gesture recognizers and discreet gesture recognizers as regards the exclusiveness?

Thanks.

Update:

Someone on StackOverflow pointed me to this shouldRequireFailure(of:) method of UIGestureRecognizer. The following is just my guess (I will test the theory tomorrow):

In the UISwipeGestureRecognizer, it returns true for any UIPanGestureRecognizer, AND UIPanGestureRecognizer always get recognized before a UISwipeGestureRecognizer. So UISwipeGestureRecognizer has no chance to fire when UIPanGestureRecognizer is not .failed.

Update 2:

In the doc of UIGestureRecognizer :

The usual sequence of actions in gesture recognition follows a path determined by default values of the cancelsTouchesInView, delaysTouchesBegan, delaysTouchesEnded properties:...

Updated 3:

I have answered my question on StackOverflow.

5
strangecanadian•

If you’ve figured it out, you should answer your own question on SO

3
vingrishOP•

Yes, I will:-)

1