我在 mapview 上放置了多个引脚,我需要为所有引脚显示不同的图像,因为我正在执行以下代码。
- (void)dropMultiplePinAnnotation:(NSArray *)arrThumbnail
{
[self removeAnnotations:[self annotations]];
for(Annotation *Annot in arrThumbnail) {
self.pinImageName = Annot.PinImage;
Annot.coordinate = Detail.coordinate;
[self addAnnotation:Annot];
//Till ios6, after this line viewForAnnotation gets called so that I can assign new pin image everytime but in ios7 viewforAnnotation called after this loop ends so it set pin image which was latest saved in self.pinImageName
}
}
- (MKAnnotationView *)mapView:(MKMapView *)map viewForAnnotation:(id <MKAnnotation>)annotation
{
static NSString *AnnotViewID = @"annotViewID";
MKAnnotationView *annotationView = (MKAnnotationView *)[self dequeueReusableAnnotationViewWithIdentifier:AnnotViewID];
if (annotationView == nil) {
annotationView = [[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:AnnotViewID];
}
annotationView.canShowCallout = NO;
annotationView.image = [UIImage imageNamed:self.pinImageName];
annotationView.annotation = annotation;
return annotationView;
}