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 中)便利类之一。

使用这些,捕获手势就像在代码中添加类似以下内容一样简单:

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 回答