以下は機能しません—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本)の指だけが範囲外のようです。3本の指のジェスチャーに関する投稿がたくさんあるので、なぜそうなのかわかりません。
self.window.multipleTouchEnabledはYESです。
テストの目的で、すべてのサブビューを削除しました。画面にはself.windowしかありません。
私はまだiOS4.3を使用していますが、UISwipeGestureRecognizerはiOS 3.2で利用可能だったので、なぜそれが問題になるのかわかりません。