我有一个带有许多具有不同图像的图钉的地图视图!一切正常,但如果我更改地图类型...正常..卫星或 ibrid..我失去了我的形象,我的别针变成了标准的红色别针!我可以更改地图类型而不更改任何内容吗?
我使用此代码分配不同的图像:
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation
{
annView = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:nil];
if([annotation.title compare:@"Biggest"]==0){imageView = [UIImage imageNamed:@"pin.png"];annView.image=imageView;}
if([annotation.title compare:@"Campo sportivo"]==0){imageView = [UIImage imageNamed:@"mondo.png"];annView.image=imageView;}
if([annotation.title compare:@"BlackSheep ADV"]==0){imageView = [UIImage imageNamed:@"an.png"];annView.image=imageView;}
annView.pinColor = MKPinAnnotationColorRed;
UIButton *advertButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
[advertButton addTarget:self action:@selector(button:) forControlEvents:UIControlEventTouchUpInside];
annView.rightCalloutAccessoryView = advertButton;
annView.animatesDrop = TRUE;
annView.canShowCallout = YES;
annView.calloutOffset = CGPointMake(0, 5);
if ([annotation isKindOfClass:[MKUserLocation class]]){
return nil;
}
return annView;
}