Mapkit pin kolor nie zmienia

głosy
3

Robię co następuje i zawsze zielonych szpilek:

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

PIN jest typu „NSObject”. Wszystkie piny wyjdzie jako zielone. Powinienem to robić inaczej?

Utwórz 11/03/2010 o 21:34
źródło użytkownik
W innych językach...                            


1 odpowiedzi

głosy
7

Upewnij się, że klasa pin implementuje MKAnnotation protokół i wierzę, aby uzyskać niestandardowe pin kolor, trzeba będzie wdrożyć viewForAnnotation metody.

- (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;
}
Odpowiedział 11/03/2010 o 21:52
źródło użytkownik

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