以下不起作用 -handleSwipeUpTriple
永远不会被调用:
- (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.");
}
}
奇怪的是,如果我将 numberOfTouchesRequired 更改为 1 甚至 2,它会起作用。似乎只有 3 个(或 4 个)手指超出范围。由于我看到很多关于三指手势的帖子,我不明白为什么会这样。
self.window.multipleTouchEnabled 是 YES。
出于测试目的,我删除了所有子视图。屏幕上只有 self.window 。
我仍在使用 iOS 4.3,但由于 iOS 3.2 可以使用 UISwipeGestureRecognizer,我不明白为什么这会是个问题。