开发者

Multitouch basics (3 or more fingers)

开发者 https://www.devze.com 2023-04-05 09:18 出处:网络
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

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
    }
}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号