MapKit Stiftfarbe nicht ändert

stimmen
3

Ich mache das folgende und immer grüne Stifte erhalten:

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

Stift ist vom Typ „NSObject“. Alle Pins kommen als grün aus. Soll ich es anders machen?

Veröffentlicht am 11/03/2010 um 21:34
quelle vom benutzer
In anderen Sprachen...                            


1 antworten

stimmen
7

Stellen Sie sicher , dass Sie Ihre PIN - Klasse implementiert das MKAnnotation Protokoll und ich glaube , eine Nicht-Standard - Pin Farbe zu erhalten, müssen Sie die implementieren müssen viewForAnnotation Methode.

- (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;
}
Beantwortet am 11/03/2010 um 21:52
quelle vom benutzer

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