Use a gesture recognizer that uses this handler:
- (void)handleGesture:(UIGestureRecognizer*)gesture
{
CGPoint locationInView = [gesture locationInView:self.view];
// do stuff
}
Frage
How can I get a CGPoint of a users touch?
It's actually a MKMapView, but since it inherits from a UIView, I'm thinking it's the same.
I can add a UIGestureRecognizer. But what I'm looking to, is to track the finger's position as it moves in the map view.
Thank you!
Lösung
Use a gesture recognizer that uses this handler:
- (void)handleGesture:(UIGestureRecognizer*)gesture
{
CGPoint locationInView = [gesture locationInView:self.view];
// do stuff
}
Andere Tipps
The implementation below updates the coordinates when you drag and touches on the screen.
-(void) touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
CGPoint coordinate = [[touches anyObject] locationInView:self.view];
self.coordinateLabel.text = [NSString stringWithFormat:@"%f, %f",coordinate.x,coordinate.y];
}