2017-07-08 3 views
0

Kann das Annotationsbild des Benutzerstandorts ändern. Vielleicht könnte jemand sehen, wo ich mich nicht irre, wenn ...Benutzerdefinierte Annotation für Userlocation Pin

-(MKAnnotationView *) mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation { 
    if ([annotation isKindOfClass:[MKUserLocation class]]) { 
     NSString* AnnotationIdentifier = @"Annotation"; 
     MKAnnotationView *annoationView = [mapView dequeueReusableAnnotationViewWithIdentifier:AnnotationIdentifier]; 
     [annoationView setImage:[UIImage imageNamed:@"melocation"] ]; 
     return annoationView; 
    } 
} 

Antwort

1

Sie haben vergessen, die Anmerkung zum ersten Mal zu initialisieren, wenn es nicht aus der Warteschlange entfernt werden kann:

-(MKAnnotationView *) mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation { 
    if ([annotation isKindOfClass:[MKUserLocation class]]) { 
     static NSString* const kAnnotationIdentifier = @"Annotation"; 
     MKAnnotationView *annoationView = [mapView dequeueReusableAnnotationViewWithIdentifier:kAnnotationIdentifier]; 
     if (!annoationView) { 
      annoationView = [[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:kAnnotationIdentifier]; 
     } 
     [annoationView setImage:[UIImage imageNamed:@"melocation"] ]; 
     return annoationView; 
    } 
    return nil; 
} 
+0

Oh Mann ... Wie du gesagt hast, ich habe es vergessen. Danke! – ironRoei

Verwandte Themen