Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS - detect when more than one finger is on the screen

I'm looking for the best way to detect more than one finger on the screen at time. I'm not detecting taps or pinching, just the fact that more than one touch is happening. There don't seem to be any gesture recognizers for that. What's the best way?

like image 553
sol Avatar asked Sep 30 '10 17:09

sol


3 Answers

In the touchesBegan, touchesMoved, and touchesEnded methods, one parameter is event, which is a UIEvent object. The number of fingers on the screen is [[event allTouches]count].

[EDITED because Josh Hinman pointed out that I had it wrong before -- my previous suggestion of using [touches count] on the touches parameter in those same methods will not work.]

like image 59
William Jockusch Avatar answered Oct 14 '22 09:10

William Jockusch


Read up on the -touchesBegan:withEvent: method. It's the entry point into multi-touch event handling.

Here's a developer's lib link on multitouch events: https://developer.apple.com/library/ios/#documentation/EventHandling/Conceptual/EventHandlingiPhoneOS/MultitouchEvents/MultitouchEvents.html

like image 4
Dan Ray Avatar answered Oct 14 '22 09:10

Dan Ray


  • (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {

    NSLog(@"%lu",[[event allTouches] count]); }

like image 1
amisha.beladiya Avatar answered Oct 14 '22 11:10

amisha.beladiya