Ios5 MKAnnotationView没有';不显示自定义pin
我正在为地图实现一个自定义pin,图像在te项目的文件夹中,但没有显示。 也许(而且很可能)我做错了什么 该地图显示并显示PIN(默认红色PIN),但不显示自定义图像或Ios5 MKAnnotationView没有';不显示自定义pin,ios5,ios6,mapkit,Ios5,Ios6,Mapkit,我正在为地图实现一个自定义pin,图像在te项目的文件夹中,但没有显示。 也许(而且很可能)我做错了什么 该地图显示并显示PIN(默认红色PIN),但不显示自定义图像或uiButtonTypedTails 这是我正在使用的代码: - (MKAnnotationView *)mapView:(MKMapView *)theMapView viewForAnnotation:(id<MKAnnotation>)annotation { // in case it's the user
uiButtonTypedTails
这是我正在使用的代码:
- (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;
}
-(MKAnnotationView*)映射视图:(MKMapView*)注释的映射视图:(id)注释
{
//如果是用户位置,我们已经有了注释,所以只需返回nil
if([annotation isKindOfClass:[MKUserLocation类]])
{
返回零;
}
静态NSString*TheAnnotationIdentifier=@“TheAnnotationIdentifier”;
MKAnnotationView*shoppeAnnotationView=
[self.mapView dequeuereusableannotationview with identifier:TheAnnotationIdentifier];
if(shoppeAnnotationView==nil)
{
MKAnnotationView*annotationView=[[MKAnnotationView alloc]initWithAnnotation:annotation重用标识符:annotationidentifier];
annotationView.canShowCallout=是;
annotationView.image=[UIImage ImageName:@“pin.png”];
annotationView.rightCalloutAccessoryView=[UIButton Button,类型:UIButtonTypedTailDisclosure];
annotationView.不透明=否;
返回注释视图;
}
返回零;
}
有什么提示吗
谢谢大家! 如果(shoppeAnnotationView==nil),则在条件的开始处,在
if(shoppeAnnotationView==nil)之后的大括号内放置一个NSLog或断点。那代码运行过吗?你修好了吗?我也面临同样的问题