Reputation: 3108
How do I get the co-ordinates of 2 touches on an iPhone? (both co-odiantes)??? This is killing me... any sample code would be great. Thanks.
Upvotes: 1
Views: 686
Reputation: 44633
If you are using touchesBegan:withEvent:
and its siblings, you will be passed an NSSet
object containing all the touches. You can get an NSArray
using allObjects
method on the set. You can retrieve individual UITouch
objects using objectAtIndex:
method. The UITouch
object can give you coordinates based on any view's frame through the method locationInView:
. The call will be on the lines of CGPoint point = [touch locationInView:self.view];
. Do this for all the touches in the array.
If you are using gesture recognizers, the gesture recognizer object has a method numberOfTouches
that gives you the number of touches and you can retrieve the location of each touch using locationOfTouch:inView:
.
Upvotes: 4
Reputation: 15628
check touches began, touches moved, touches ended, and touches cancelled. here is the link for this UIResponder class reference
Upvotes: 1