Using multi-touch on iPhone & iPad
How do I get the co-ordinates of 2 touches on an iPhone? (both co-odiantes)??? This is killing me... any 开发者_JAVA技巧sample code would be great. Thanks.
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:
.
check touches began, touches moved, touches ended, and touches cancelled. here is the link for this UIResponder class reference
精彩评论