我在mapview上放置了多個針腳,我需要爲所有針腳顯示不同的圖像,因爲我正在執行下面的代碼。Mapview delegete在ios7中添加註解時未調用
- (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;
}
它被調用。所以我們可以從它已經確定 – Heena