Why and how does UIPanGestureRecognizer mute UISwipeGestureRecognizer while UITapGestureRecognizers don't mute each other by default?
stackoverflow.com/questions/54403785/why-and-...Posted Jan 28, 2019, 2:18 PM UTC
233
Posted Jan 28, 2019, 2:18 PM UTC
In the doc Coordinating Multiple Gesture Recognizers, it says,
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
UIGestureRecognizerDelegatemethodgestureRecognizer(_:shouldRecognizeSimultaneouslyWith:)comes into play externally. But how can the system built-in gesture recognizers, such asUITapGestureRecognizer, 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 ofUIGestureRecognizer. The following is just my guess (I will test the theory tomorrow):In the UISwipeGestureRecognizer, it returns true for any UIPanGestureRecognizer,ANDUIPanGestureRecognizer 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:Updated 3:
I have answered my question on StackOverflow.
If you’ve figured it out, you should answer your own question on SO
Yes, I will:-)