views:

45

answers:

1

Is there a way to get the coordinates off all touches currently on the display at any given time without having to keep track of all of the touchesBegan, touchesMoved, and touchesEnded. Because as far as I can tell getting the coordinates within any one of these functions by doing:

NSSet *allTouches = [event allTouches];
UITouch *touch = [[allTouches allObjects] objectAtIndex:0];
...

only reports the touches that move end or start. I need to the the cords off all fingers not just the fingers who's locations have changed.

A: 

There is no built in way to do this.

The way I've done it in the past is to keep a list of coordinates, add to that in touchesBegan, update those based on the the closest touch in proximity to the points in that list in touchesMoved, and remove based on the nearest proximity in touchesEnded and Cancelled.

All in all its not too bad, you can also attach state information to these updates to give you a system to poll and get a list of all current touches and their current state.

Joshua Weinberg
I believe you could use the '- (CGPoint)previousLocationInView:(UIView *)view' method to figure out which touch actually moved, rather than using proximity.
Nicholas M T Elliott