MapKit color de pin no cambia

votos
3

Estoy haciendo lo siguiente y siempre conseguir pasadores verdes:

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

pin es de tipo NSObject. Todos los pines salen tan verde. Debería hacer de manera diferente?

Publicado el 11/03/2010 a las 21:34
fuente por usuario
En otros idiomas...                            


1 respuestas

votos
7

Asegúrese de que su clase implementa el pin MKAnnotation protocolo y creo que para obtener un color perno no estándar, que tendrá que poner en práctica el viewForAnnotation método.

- (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;
}
Respondida el 11/03/2010 a las 21:52
fuente por usuario

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