您好,我实现了这个功能,我可以手势,但我如何识别哪个手势是什么?例如简单地向左或向右移动?
我的处理代码:
/*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];
}
感谢您的回答
最佳答案
嗯,这很大程度上取决于您想要捕获什么手势。如果是简单的捏合、轻扫等操作,那么您可能应该使用 this document 中描述的 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
}
这将捕获双击。
关于cocoa - 识别手势的简单方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5313980/