Edit: I missed what you said you couldn't use 3.x gestures, so this is the wrong answer to your question, but I leave it in case someone who can use 3.x gestures can benefit from this.
You can create two gesture recognizers: one for one tap and one for double tap:
UITapGestureRecognizer *singleTapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTouchesOne:)]; singleTapGesture.cancelsTouchesInView = NO; singleTapGesture.delaysTouchesEnded = NO; singleTapGesture.numberOfTouchesRequired = 1; // One finger single tap singleTapGesture.numberOfTapsRequired = 1; [self.view addGestureRecognizer:singleTapGesture]; [singleTapGesture release]; UITapGestureRecognizer *doubleTapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTouchesTwo:)]; doubleTapGesture.cancelsTouchesInView = NO; doubleTapGesture.delaysTouchesEnded = NO; doubleTapGesture.numberOfTouchesRequired = 1; // One finger double tap doubleTapGesture.numberOfTapsRequired = 2; [self.view addGestureRecognizer:doubleTapGesture]; [doubleTapGesture release];
And now, here comes the blow:
[singleTapGesture requireGestureRecognizerToFail : doubleTapGesture]
The last line makes your single descriptor a handler only if the double tap fails. This way you get both a single tap and a double tap in your application.
aslisabanci
source share