【问题标题】:mkmapview showsUserLocationmkmapview 显示用户位置
【发布时间】:2011-11-14 08:05:41
【问题描述】:

您好,这里有一个问题。 我正在尝试做。

if (Map.showsUserLocation == YES) 
        {
            Map.showsUserLocation = NO;
        }

这很简单。应用刚启动时showsUserLocation设置为YES,但设备需要时间才能找到位置。因此,如果用户在找到位置之前(在蓝点出现之前)单击showsUserLocation = NO。 EXC_BAD_ACCESS。

在谷歌地图中,​​它有保护代码,在谷歌地图出现蓝点之前,它会通过显示activityIndi​​cator来禁止你按showsUserLocation按钮。 知道怎么做吗? 提前致谢。

【问题讨论】:

  • 我没有完全理解。你想做什么???

标签: iphone objective-c mkmapview exc-bad-access showuserlocation


【解决方案1】:

MKMapViewDelegate 有一个方法:

- (void)mapView:(MKMapView *)mapView didUpdateUserLocation:(MKUserLocation *)userLocation

您可以在此处启用该按钮,然后将其保持禁用状态。

【讨论】:

  • 谢谢兄弟。我知道这种方法。但我的大脑就是想不出这种办法。
【解决方案2】:

你可以做得很舒服。禁用“currentLocation”按钮,直到 mapView 获取用户的当前位置,然后在获取用户的当前位置时使用“currentLocation”按钮。您可以通过禁用 viewDidLoad/ViewDidAppear 中的“currentLocation”按钮并在-(MKAnnotationView *)mapView:(MKMapView *)mV viewForAnnotation: 方法中启用“currentLocation”按钮来执行此操作在[mapView.userLocation setTitle:@"I am here"]; 之后。这对你有用。

【讨论】:

    猜你喜欢
    • 2011-08-30
    • 1970-01-01
    • 1970-01-01
    • 2012-11-29
    • 1970-01-01
    • 2013-04-17
    • 2015-01-29
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多