I’m using two different TapGestureRecognizer to handle both single and double tap on screen.
This is the code:
UITapGestureRecognizer *tapGR =[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(handleTap:)];
[tapGR setDelegate:self];
[tapGR setNumberOfTapsRequired:1];
[self addGestureRecognizer:tapGR];
UITapGestureRecognizer *doubleTapGR = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(handleDoubleTap:)];
[doubleTapGR setNumberOfTouchesRequired:2];
[self addGestureRecognizer:doubleTapGR];
[tapGR requireGestureRecognizerToFail : doubleTapGR];
[tapGR release];
[doubleTapGR release];
Even if I specified that [tapGR requireGestureRecognizerToFail: doubleTapGR] the “handleTap” selector is performed. Where is the mistake?
You made a mistake! You used
setNumberOfTouchesRequiredmethod fordoubleTapGRinstead of usingsetNumberOfTapsRequired. Here is the corrected code:Best regards 😉