How to create Touch Events for MKMapView. I'm using UIViewController and adding MKMapView on that using interface builder. Now I need to handle touch events for that map.....
I tried by writing UI开发者_开发问答Touch Delegate methods But I failed...It is not getting called.
Please post a solution how to handle touch events on MKMapView.....
Thanks in advance...
If you are happy with an iOS 4 and above solution, I've used UIGesture recognisers and never had a problem.
Here's an example for a long pressure gesture (tap and hold):
// Long press gesture recogniser
UILongPressGestureRecognizer *longPressGesture = [[UILongPressGestureRecognizer alloc]
initWithTarget:self
action:@selector(handleLongPressGesture:)];
[self.view addGestureRecognizer:longPressGesture];
[longPressGesture release];
And then you can handle the even in your handleLongPressGesture:
method:
-(void)handleLongPressGesture:(UILongPressGestureRecognizer*)sender
{
if (sender.state == UIGestureRecognizerStateEnded || sender.state == UIGestureRecognizerStateChanged)
return;
else {
// Your app logic here...
}
}
精彩评论