0

I am using a mutable array to render annotations on a map ,, the problem is when I tap on the disclosure button in any annotation in the map I can't get the title of that annotation because I don't know how to get its index and I would like to print it in mapLabel ... but I can't find the index of this annotation

and Here is the code:

-(MKAnnotationView *) mapView:(MKMapView *)mapMKMapView viewForAnnotation:      (id<MKAnnotation>)annotation
{
MKPinAnnotationView *MyPin=[[MKPinAnnotationView alloc] initWithAnnotation:annotation      reuseIdentifier:@"current"];
MyPin.pinColor = MKPinAnnotationColorPurple;

UIButton *adverButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
[adverButton addTarget:self action:@selector(button:) forControlEvents:UIControlEventTouchUpInside];

MyPin.rightCalloutAccessoryView = adverButton;
MyPin.draggable = YES;
MyPin.highlighted = YES;
MyPin.animatesDrop  = TRUE;
MyPin.canShowCallout  = YES;

return MyPin;
}

-(void)button:(id)sender
{
  //mapLabel.text =  @"Here is the chosen ann title";
}
  • In your previous question, I mentioned using the calloutAccessoryControlTapped delegate method would make this easier. Also see http://stackoverflow.com/questions/9462699/how-to-recognize-which-pin-was-tapped and http://stackoverflow.com/questions/9876042/annotation-details-after-detail-disclosure-pressed. –  Nov 27 '13 at 18:03
  • Thanks @AnnaKarenina that was useful. I wish I could vote :) – Abdulmalik Morghem Nov 30 '13 at 15:51

0 Answers0