I have a view. I wish to define to kinds of tap gestures for it.
So if a user single tap on the view, view will do A; and if a user double tap on the view, it will do B without doing A.
I added two UITapGestureRecognizer to the view. the single tap is with numberOfTapsRequired = 1; and the double tap is with numberOfTapsRequired = 2;
Also I set return NO for
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer {
return NO;
}
However, I found that they conflict with each other. I mean, even if I double tap on the view, both A and B will be invoked.
How can I solve this pro开发者_开发问答blem?
Thanks
You can work around this by adding the following line of code. This will make sure that the single tap recognizer only fires when the double tap recognizer failed:
[singleTapRecognizer requireGestureRecognizerToFail:doubleTapRecognizer];
精彩评论