2011-03-15 75 views
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]; 

} 

感谢您的任何答案

回答

2

嗯,这完全取决于你想要什么样的陷阱姿态。如果它是一个简单的捏,滑动水龙头等,那么你应该使用this document中描述的苹果新(在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 
} 

这将陷阱双击。