MapKit colore perno non cambia

voti
3

Sto facendo quanto segue e sempre ottenere perni verdi:

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

pin è di tipo NSObject. Tutti i perni fuoriescano come verde. Dovrei fare in modo diverso?

È pubblicato 11/03/2010 alle 21:34
fonte dall'utente
In altre lingue...                            


1 risposte

voti
7

Assicurarsi che la classe implementa il pin MKAnnotation protocollo e credo che per ottenere un colore pin non standard, si dovrà implementare il viewForAnnotation metodo.

- (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;
}
Risposto il 11/03/2010 a 21:52
fonte dall'utente

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