J'affiche des images personnalisées sur une carte (au lieu des broches par défaut) en utilisant le code ci-dessous. Cependant, lorsque je tape sur un élément (et que la légende apparaît), l'image revient à la broche rouge par défaut. Comment puis-je conserver mon image personnalisée, même lorsque la légende est affichée?Annotation personnaliséeAfficher les images sur les broches lorsque l'utilisateur clique sur
- (MKAnnotationView *) mapView:(MKMapView *)map viewForAnnotation:(id <MKAnnotation>)annotation
{
MKPinAnnotationView *pinAnnotation = nil;
if (annotation != mapView.userLocation)
{
static NSString *pinID = @"mapPin";
pinAnnotation = (MKPinAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:pinID];
if (pinAnnotation == nil)
pinAnnotation = [[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:pinID] autorelease];
// Set the image
pinAnnotation.image = [UIImage imageNamed:@"TestIcon.png"];
// Set ability to show callout
pinAnnotation.canShowCallout = YES;
// Set up the disclosure button on the right side
UIButton *infoButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
pinAnnotation.rightCalloutAccessoryView = infoButton;
[pinID release];
}
return pinAnnotation;
[pinAnnotation release];
}