0

I place some custom MKPinAnnotationView on the map, with different information about landmarks (name, description, image, accessory button). When a user click and open one of the pins, and then click the accessory button inside it, I want to know which of the pins the user have clicked so I can load a viewcontroller with more detailed information.

I found these methods:

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

- (void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)view   
{
}

... but how do I know which pin was selected? I would like to do something like:

   - (void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)view   
    {
        //Example
        if ([view.description isEqualToString: @"Golden Gate"])
        {
             //Load golden gate information in a new viewcontroller
        }
    }

...but view.description won't give me the right information.

Thanks in advance

BlackMouse
  • 4,442
  • 6
  • 38
  • 65

1 Answers1

3

If you're storing the name/description in the title/subtitle of your MKAnnotationView you can access these informations just by accessing to the annotation property of the MKAnnotationView:

if ([view.annotation.title isEqualToString: @"Golden Gate"])
   {
         //Load golden gate information in a new viewcontroller
   }
Mat
  • 7,613
  • 4
  • 40
  • 56