以下のコードを実行しているため、すべてのピンに対して異なる画像を表示する必要があるマップビューに複数のピンをドロップしています。
- (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;
}