是否有办法防止启用MKMapView实例中的注释。换句话说,当用户点击地图上的红色图钉时,有没有办法阻止它突出显示图钉。现在,触摸时引脚会变暗......
编辑:我正在使用以下代码返回MKPinAnnotationView
// To future MKMapView users - Don't forget to set _mapView's delegate
_mapView.delegate = self;
_annotation = [[MKPointAnnotation alloc] init];
_annotation.coordinate = myLocation;
[_mapView addAnnotation:_annotation];
-(MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation{
MKPinAnnotationView *pin = [[MKPinAnnotationView alloc] initWithAnnotation:_annotation reuseIdentifier:@"id"];
pin.enabled = NO;
return pin;
}
答案 0 :(得分:3)
将enabled
设置为NO
,MKPinAnnotationView
,您从-mapView:viewForAnnotation:
委托方法返回(如果您尚未实施,请执行此操作)。
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation
{
static NSString *annotationIdentifier = @"Annotation";
MKPinAnnotationView *annotationView = (MKPinAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:annotationIdentifier];
if (!annotationView) {
annotationView = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:annotationIdentifier];
}
else {
annotationView.annotation = annotation;
}
annotationView.enabled = NO;
return annotationView;
}