首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >扩展mapView:viewForAnnotation现在没有蓝点

扩展mapView:viewForAnnotation现在没有蓝点
EN

Stack Overflow用户
提问于 2010-09-11 00:43:10
回答 1查看 5.5K关注 0票数 13

我用以下代码扩展了MapKit绘制自定义注释图像的能力:

代码语言:javascript
复制
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation{
    NSLog(@"Drawing a cloud on the map");
    MKAnnotationView *view;
    if(annotation != mapView.userLocation){
        view=[[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"parkingloc"];
        view.image=[UIImage imageNamed:@"placemarkCloud.png"];
        [view setCanShowCallout:YES];
        [view setRightCalloutAccessoryView:[UIButton buttonWithType:UIButtonTypeDetailDisclosure]];
    }
    else{
        view=
    }
    return view;
}

我的问题是,为了保留iPhone内置的蓝点,我应该做什么view = to。您可以看到,我删除了为点绘制的自定义图像,但我不知道如何将其显示为默认图像。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2010-09-11 11:32:40

不要在其他地方放任何东西。我执行以下检查。我认为这是从Apple示例代码派生而来的。

代码语言:javascript
复制
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation{

if ([annotation isKindOfClass:[MKUserLocation class]]) {
  //Don't trample the user location annotation (pulsing blue dot).
  return nil;
}

//Continue on to your regular code here.
票数 47
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/3686515

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档