嗨我实现了这个功能,我可以手势,但我怎么能识别哪个手势是什么?例如简单地向左或向右移动?
我的处理代码:
/*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];
}
感谢您的回答
答案 0 :(得分:2)
嗯,这很大程度上取决于你想要陷阱的姿势。如果它是一个简单的捏,轻击水龙头等,那么你应该使用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
}
这将陷入双击。