Jeg gjør følgende, og alltid få grønne pins:
pin.pinColor = MKPinAnnotationColorRed;
[self.mapView addAnnotation:pin];
[pin release];
stiften er av typen NSObject. Alle pinnene kommer ut som grønne. Bør jeg gjøre det annerledes?
Jeg gjør følgende, og alltid få grønne pins:
pin.pinColor = MKPinAnnotationColorRed;
[self.mapView addAnnotation:pin];
[pin release];
stiften er av typen NSObject. Alle pinnene kommer ut som grønne. Bør jeg gjøre det annerledes?
Sørg for at pinnen klassen implementerer MKAnnotation protokollen, og jeg mener å få en ikke-standard pin farge, må du implementere viewForAnnotation metoden.
- (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;
}