0

我正在为地图实现自定义图钉,图像位于项目文件夹中但未显示。也许(而且很可能)我做错了什么。

地图显示并显示引脚(默认红色引脚),但不显示自定义图像或UIButtonTypeDetailDisclosure

这是我正在使用的代码:

- (MKAnnotationView *)mapView:(MKMapView *)theMapView viewForAnnotation:(id<MKAnnotation>)annotation
{

// in case it's the user location, we already have an annotation, so just return nil
if ([annotation isKindOfClass:[MKUserLocation class]])
{
    return nil;
}
 static NSString *TheAnnotationIdentifier = @"theAnnotationIdentifier";

MKAnnotationView *shoppeAnnotationView =
[self.mapView dequeueReusableAnnotationViewWithIdentifier:TheAnnotationIdentifier];
if (shoppeAnnotationView == nil)
{
    MKAnnotationView *annotationView = [[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:TheAnnotationIdentifier];

    annotationView.canShowCallout = YES;

    annotationView.image = [UIImage imageNamed:@"pin.png"];
    annotationView.rightCalloutAccessoryView = [ UIButton buttonWithType:UIButtonTypeDetailDisclosure ];
    annotationView.opaque = NO;

    return annotationView; 
}
    return nil;
}

有什么提示吗?

谢谢!

4

0 回答 0