当前位置注释默认看看?

时间:2012-10-21 16:52:01

标签: ios mapkit mkannotation mkannotationview

我有以下代码:

- (MKAnnotationView *) mapView:(MKMapView *) mapView viewForAnnotation:(id ) annotation {

    MKPinAnnotationView *customAnnotationView=[[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:nil] autorelease];

    customAnnotationView.pinColor = MKPinAnnotationColorRed;
    customAnnotationView.animatesDrop = NO;
    customAnnotationView.canShowCallout = YES;

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

    customAnnotationView.rightCalloutAccessoryView = rightButton;

    return customAnnotationView;
}

此方法更改mapview上的每个注释,包括当前位置蓝色圆圈注释。我想只更改自定义注释并单独保留当前位置注释。

我该怎么做?

1 个答案:

答案 0 :(得分:5)

如果注释是userLocation注释,则返回nil

if(annotation == mapView.userLocation){
    return nil;
}