2017-07-08 105 views
0

似乎可以改變用戶位置註釋圖像。 也許有人可以看到我的錯,如果...用戶位置註釋的自定義註釋

-(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; 
    } 
} 

回答

1

你忘了初始化首次註釋,當它不能出列:

-(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

哦的人... 正如你所說我忘了它。 謝謝! – ironRoei