What is the time limit for two taps to be considered a double-tap, on the iPhone OS?
// Edit: Why is this important?
In order to handle single-tap and double-tap
I am not sure if this is the correct way of doing things but this code is working well for me.
in my .h file:
@interface MyViewController : UIViewController {
int tapCount;
}
@property (nonatomic, assign)int tapCount;
@end
in my .m file:
@synthesize tapCount;
- (void)tapGesture:(UIGestureRecognizer*)gesture {
tapCount = tapCount + 1;
[self performSelector:@selector(correctTapCount) withObject:nil afterDelay:0.3];
}
-(void)correctTapCount {
if (tapCount == 1) {
NSLog(@"Single Tap");
}
if (tapCount == 2) {
NSLog(@"Double Tap");
}
//reset TapCount
tapCount = 0;
}
And this is where I add my tap listener (it is on a UIImageView )
//add tap listener
carImage.userInteractionEnabled = YES;
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapGesture:)];
[carImage addGestureRecognizer:tap];
[tap release];
Good Luck and Happy Coding!