2012-04-11 14 views
2

Ich habe diesen Code verwendet, um die Farbe der Anmerkung zu ändern, aber danach können der Titel und der Untertitel nicht angezeigt werden, wie kann ich dieses Problem speichern?Anmerkung Titel kann nicht angezeigt werden, nachdem die pincolor geändert

Der Code lautet:

- (MKAnnotationView *)mapView:(MKMapView *)mV viewForAnnotation:(id <MKAnnotation>)annotation 
{ 
    static NSString *defaultPinID = @"LYB"; 
    MKPinAnnotationView *customPinview = (MKPinAnnotationView *)[_mapView dequeueReusableAnnotationViewWithIdentifier:defaultPinID]; 
    if (customPinview == nil) { 
     customPinview = [[[MKPinAnnotationView alloc] 
        initWithAnnotation:from reuseIdentifier:defaultPinID] autorelease]; 
    } 
    if ([annotation isKindOfClass:[MKUserLocation class]]) 
     return nil; 
    if ([[annotation title] isEqualToString:@"the first"]) { 
     customPinview.pinColor = MKPinAnnotationColorGreen; 
    } 
    return customPinview; 
} 

Antwort

2

Fügen Sie den folgenden Code in einer neuen Zeile vor "Rückkehr customPinview":

customPinview.canShowCallout = YES;