【问题标题】:iPhone: How to reenable MKUserLocation 'blue dot'?iPhone:如何启用 MKUserLocation '蓝点'?
【发布时间】:2010-09-02 09:43:18
【问题描述】:

启用“蓝点”显示我的应用程序中的当前位置

mapView.showsUserLocation = YES

通过

禁用/隐藏点
mapView.showsUserLocation = NO

为了放下图钉。到现在为止还挺好。

在“userLocation”处添加注释图钉并将其在地图中拖动到新位置。之后,我想通过再次将 showUserLocation 设置为 YES 来再次显示蓝点 - 但它根本不显示!可能是什么问题呢?有没有办法用任何其他方法强制它再次显示(重置 userLocation?)?涉及哪些事件?

感谢您对此的任何帮助..

【问题讨论】:

    标签: iphone annotations mkmapview


    【解决方案1】:

    检查您是否正在使用- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation 方法尝试自定义 annotationView:

    if (annotation==_mapView.userLocation ) {
        return nil;
    }
    else {
        //...
        //costumizing pins for other annotations on mapview
    
        //return customized annotationview
    }
    

    【讨论】:

    • 我不确定为什么上面的代码对我有用。但是 Will Johnson 的代码可以解决问题。
    • 我关闭再打开定位服务就不行了。
    【解决方案2】:

    试试这个:

    if ([annotation isKindOfClass:[MKUserLocation class]])  return nil;
    

    使用类而不是 annotation==_mapView.userLocation 意味着你停止使用 _mapView.userLocation 或其他什么,这条线不会中断。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-06-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-08-30
      • 1970-01-01
      相关资源
      最近更新 更多