1

こんにちは、私はこの機能を実装し、ジェスチャーを渡すことができますが、どのジェスチャーがどれであるかをどのように認識できますか?たとえば、単純に左または右に移動しますか?

処理のための私のコード:

/*this function is made to handel finger gesture and flip the view to other account*/
-(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{



    FirstViewController *screen = [[FirstViewController alloc] initWithNibName:nil bundle:nil];

    screen.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
    screen.myArray = myArray;    
    [self presentModalViewController:screen animated:YES];
    [screen release];

} 

答えてくれてありがとう

4

1 に答える 1

2

まあ、それはあなたがトラップしたいジェスチャーに大きく依存します。単純なピンチ、スワイプタップなどの場合は、このドキュメントで説明されているAppleの新しい(3.2の)便利なクラスの1つを使用する必要があります。

これらを使用すると、ジェスチャをトラップするのは、コードに次のようなものを追加するのと同じくらい簡単です。

UITapGestureRecognizer *doubleFingerDTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleDoubleDoubleTap:)];
doubleFingerDTap.numberOfTapsRequired = 2;
[self.view addGestureRecognizer:doubleFingerDTap];

次に、ジェスチャが見つかったときにジェスチャを処理するメソッドを実装します。

- (void)handleDoubleDoubleTap:(UIGestureRecognizer *)sender {
      //Do something here
}

これはダブルタップをトラップします。

于 2011-03-15T15:37:33.927 に答える