2011-03-15 78 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 
} 

這將陷阱雙擊。