Question

I want to check if the annotation is clicked: So it goes from this:

Not clicked yet

To :

To clicked

Here's my code that shows the annotation:

- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation {
static NSString *identifier = @"MyLocation";

if ([annotation isKindOfClass:[MyLocation class]]) {


    MKAnnotationView *annotationView = (MKAnnotationView *) [_mapView dequeueReusableAnnotationViewWithIdentifier:identifier];

    if (annotationView == nil) {
        annotationView = [[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:identifier];
        annotationView.enabled = YES;
        annotationView.canShowCallout = YES;
        annotationView.image = [UIImage imageNamed:@"arrest.png"];//here we use a nice image instead of the default pins
        annotationView.rightCalloutAccessoryView = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];


    } else {
        annotationView.annotation = annotation;

    }

    return annotationView;

}

return nil;

}

the rightCalloutAccesoryView is a blue button inside the callout. But i need to hide something when the user clicks on the annotation.

Does anyone know how to check this/do this?

Thanks is advance

Was it helpful?

Solution

- (void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)view {
//do your code
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top