How do I detect two fingers tap on the iPhone?
For example, you can perform a two-finger tap using two fingers on one hand, one finger on each hand, or your thumbs. Instead of selecting an item and double-tapping, you can use a split-tap gesture—touch and hold an item with one finger, then tap the screen with another finger.
It's now in System Preferences -> Accessibility -> Zoom. If you are having "pinch" gestures zoom in specific zoom-capable apps, you can turn that gesture off in System Preferences -> Trackpad -> Scroll & Zoom.
If you can target OS 3.2 or above, you can use a UITapGestureRecognizer
. It's really easy to use: just configure it and attach it to the view. When the gesture is performed, it'll fire the action of the gestureRecognizer's target.
Example:
UITapGestureRecognizer * r = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(viewWasDoubleTapped:)];
[r setNumberOfTapsRequired:2];
[[self view] addGestureRecognizer:r];
[r release];
Then you just implement a - (void) viewWasDoubleTapped:(id)sender
method, and that will get invoked when [self view]
gets double-tapped.
EDIT
I just realized you might be talking about detecting a single tap with two fingers. If that's the case, the you can do
[r setNumberOfTouchesRequired:2].
The primary advantage of this approach is that you don't have to make a custom view subclass
If you're not targeting 3.2+:
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
if ([touches count] == 2) {
//etc
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With