检查是否单击了注释标注

时间:2012-11-16 07:19:50

标签: ios mapkit mkannotationview ios6-maps callout

我想检查是否点击了注释: 所以它是这样的:

Not clicked yet

致:

To clicked

这是我的代码,显示注释:

- (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;

}

rightCalloutAccesoryView是标注内的蓝色按钮。但是当用户点击注释时我需要隐藏一些东西。

有谁知道如何检查/这样做?

谢谢是提前

1 个答案:

答案 0 :(得分:3)

- (void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)view {
//do your code
}