用户位置注释的自定义注释

问题描述:

似乎可以改变用户位置注释图像。 也许有人可以看到我的错,如果...用户位置注释的自定义注释

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

你忘了初始化首次注释,当它不能出列:

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