couleur pin MapKit ne change pas

voix
3

Je fais ce qui suit et toujours obtenir broches vert:

pin.pinColor = MKPinAnnotationColorRed;
        [self.mapView addAnnotation:pin];
        [pin release];

la broche est de type « NSObject ». Toutes les broches sortent en vert. Dois-je faire différemment?

Créé 11/03/2010 à 21:34
source utilisateur
Dans d'autres langues...                            


1 réponses

voix
7

Assurez - vous que votre classe broches implémente le MKAnnotation protocole et je crois pour obtenir une couleur pin non standard, vous devrez mettre en œuvre la viewForAnnotation méthode.

- (MKAnnotationView *) mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>) annotation
{
    MKPinAnnotationView *newAnnotation = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"redpin"];
    newAnnotation.pinColor = MKPinAnnotationColorRed;
    newAnnotation.animatesDrop = YES;
    newAnnotation.canShowCallout = YES;
    return newAnnotation;
}
Créé 11/03/2010 à 21:52
source utilisateur

Cookies help us deliver our services. By using our services, you agree to our use of cookies. Learn more