I've noticed a lack of questions related to true multi-touch in iOS. I'm not talking about touch events for one finger, I'm talking about touch events for 3 or more fingers. Are there any sources or documentation articles about gesture handling for large amounts of touch input? And if not, are there any b开发者_JAVA技巧ase methods that any of you have used in the past that work?
(P.S. My ultimate goal is to NSLOG a 3 finger swipe down).
Use gesture recognizers—they handle touch processing for you and most let you specify the minimum number of fingers for the gesture to be recognized. In your case, for example:
// -viewDidLoad
UISwipeGestureRecognizer *swipeRecognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swiped:)];
swipeRecognizer.direction = UISwipeGestureRecognizerDirectionDown;
swipeRecognizer.numberOfTouchesRequired = 3;
[self.view addGestureRecognizer:swipeRecognizer];
[swipeRecognizer release];
…
- (void)swiped:(UISwipeGestureRecognizer *)recognizer
{
if(recognizer.state == UIGestureRecognizerStateRecognized)
{
// got a three-finger swipe
}
}
精彩评论