我已经尝试了这两个(MKMapView Delegate):
-(void) mapView:(MKMapView *)mapView didAddAnnotationViews:(NSArray *)views
{
for (MKAnnotationView *annotationView in views)
{
annotationView.image = [UIImage imageNamed:@"itemType2.png"];
annotationView.rightCalloutAccessoryView = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
annotationView.canShowCallout = YES;
}
}
这(在具有 MKMapView 的 VC 上):
[self.theMapView addAnnotations:annotationsArray];
for (id <MKAnnotation> itemAnnotation in self.theMapView.annotations)
{
MKAnnotationView *itemAnnotationView = [self.theMapView viewForAnnotation:itemAnnotation];
itemAnnotationView.image = [UIImage imageNamed:@"itemType2.png"];
itemAnnotationView.rightCalloutAccessoryView = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
itemAnnotationView.canShowCallout = YES;
//[self.theMapView setNeedsDisplay];
}
在更改 MKAnnotationView 的外观方面没有任何成功,它们显示为简单的红色大头针,没有披露按钮或任何东西......
是通过创建子类 MKMapView 并使用 - (MKAnnotationView *)viewForAnnotation:(id < MKAnnotation >)annotation 来更改它们的唯一方法吗?我觉得为了更改注释而创建一个额外的子类是没有必要的,为什么上述方法不起作用?