The following does not work — handleSwipeUpTriple
is never called:
- (BOOL) application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
UISwipeGestureRecognizer *swipeUpTripleRecognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipeUpTriple:)];
swipeUpTripleRecognizer.direction = UISwipeGestureRecognizerDirectionUp;
swipeUpTripleRecognizer.numberOfTouchesRequired = 3; // triple finger
// window is in nib
[self.window addGestureRecognizer:swipeUpTripleRecognizer];
[swipeUpTripleRecognizer release];
}
- (void) handleSwipeUpTriple:(UISwipeGestureRecognizer *)sender {
printf("\nhandleSwipUpTrpl called."); // never happens
if (sender.state == UIGestureRecognizerStateEnded)
printf("\n SwipeUpTriple recognized.");
}
}
The weird thing is that if I change the numberOfTouchesRequired to 1 or even 2, it works. Only 3 (or 4) fingers seem to be out of bounds. Since I see a number of posts regarding 3-finger gestures, I don’t see why this should be.
self.window.multipleTouchEnabled is YES.
For testing purposes, I have removed all subviews. There’s nothing but self.window on the screen.
I’m still using iOS 4.3, but since UISwipeGestureRecognizer was available by iOS 3.2, I don’t see why that should be a problem.
I know that the non-iPad devices sometimes are running system gesture recognizers for 3 fingers (usually zoom). Depending on your settings the system may have reserved this number of fingers for itself.
As we found, you can fix this by going to General > Accessibility and disabling the three-finger gestures.