iPhone: Question about touch events for map views
I have a mapView which has a couple of mapAnnotations. Id like to record the event when the user touches on a mapAnnoatation and then Id like to capture the information from that particular annotation and save it. I came up with the following code to get started. But I do not see any output on my console after I build and run and the tap on an annotation on my device.
What am I doing wrong?
开发者_StackOverflow- (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control
{
LocationMapAnnotation *tempAnnotation = view.annotation;
NSLog(@"The tapped annotation was %@", tempAnnotation.title);
}
From what I can remember, that particular method will only be called when an accessory view on an Annotation's callout view is tapped; so, for example, if you tap the blue icon in this screenshot:
By implementing the method
- (void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)view
you should hopefully be able to achieve what you're after.
精彩评论