0

以下は機能しません—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で利用可能だったので、なぜそれが問題になるのかわかりません。

4

1 に答える 1

1

iPad以外のデバイスでは、3本の指でシステムジェスチャレコグナイザーが実行されていることがあります(通常はズーム)。設定によっては、システムがこの数の指を自分用に予約している場合があります。

私たちが見つけたように、これを修正するには、[一般]> [ユーザー補助]に移動し、3本の指のジェスチャーを無効にします。

于 2012-06-28T16:42:32.880 に答える