我正在通过以下代码更改我的 pin 注释视图:
-(MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation {
if([annotation isKindOfClass:[MKUserLocation class]])
return nil;
static NSString *identifier=@"myAnnotation";
MapObjects *annotation1=(MapObjects*)annotation;
MKPinAnnotationView * annotationView = (MKPinAnnotationView*)[self.map_whereAreVehicles dequeueReusableAnnotationViewWithIdentifier:identifier];
if(!annotationView){
annotationView= [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:nil];
annotationView.image=[UIImage imageNamed:@"greenpin.png"];
annotationView.animatesDrop = NO;
annotationView.canShowCallout = NO;
}
else{
annotationView.annotation=annotation;
}
return annotationView;
}
这向我展示了模拟器中的图像。但是当我在 ipad 中进行测试时,那里没有显示任何内容。如果我删除图像,则默认引脚显示在两者中。设备注释中还有一件事,但它仅不可见。