Luc
Luc

Reputation: 17082

calloutAccessoryControlTapped not called in storyboard

I have a view containing a MKMapView, I display sereval pins in it:

- (MKAnnotationView *)mapView:(MKMapView *)theMapView viewForAnnotation:(id <MKAnnotation>)annotation
{
  NSLog(@"mapView:viewForAnnotation");

  // if it's the user location, just return nil.
  if ([annotation isKindOfClass:[MKUserLocation class]]){
      return nil;
  }

  static NSString* AnnotationIdentifier = @"AnnotationIdentifier";
  MKPinAnnotationView *pinView = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:AnnotationIdentifier];
  pinView.canShowCallout = YES;
  pinView.pinColor = MKPinAnnotationColorPurple;
  pinView.annotation = annotation;    

  return pinView;
}

This is working fine but the method:

-(void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control

is not called when the pin is clicked. It seems the click event is not transmitted to the pin but I cannot figure out why. Any idea ?

Upvotes: 0

Views: 3262

Answers (1)

user467105
user467105

Reputation:

When the pin itself is clicked, the map view will call the delegate method mapView:didSelectAnnotationView:.

The calloutAccessoryControlTapped method is called when an annotation view's leftCalloutAccessoryView or rightCalloutAccessoryView is tapped. These are controls (usually buttons) that appear on the pin's callout.

It sounds like you are looking for the mapView:didSelectAnnotationView: delegate method instead.

Upvotes: 6

Related Questions