I have a map view that adds annotations more or less like this:
- (MKAnnotationView *)mapView:(MKMapView *)mapView
viewForAnnotation:(id
To tap the callout button after the user has clicked on the Annotation view, add a UITapGestureRecognizer
in didSelectAnnotationView
. This way you can implement tap on the callout without needing the accessory views.
You can then get the annotation object back from the sender for further action.
- (void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)view
{
UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(calloutTapped:)];
[view addGestureRecognizer:tapGesture];
}
-(void)calloutTapped:(UITapGestureRecognizer *) sender
{
NSLog(@"Callout was tapped");
MKAnnotationView *view = (MKAnnotationView*)sender.view;
id annotation = [view annotation];
if ([annotation isKindOfClass:[MKPointAnnotation class]])
{
[self performSegueWithIdentifier:@"annotationDetailSegue" sender:annotation];
}
}