【问题标题】:MapKit, run method on location-service-permission being grantedMapKit,在授予位置服务权限时运行方法
【发布时间】:2011-12-07 04:20:34
【问题描述】:

我有一个带有 mapkit 的应用程序,它在 ViewDidLoad 期间使用 loadAnnotations 方法加载注释。但我不想运行所述方法(加载注释),直到获得使用当前用户位置的权限。这可能吗?

【问题讨论】:

    标签: iphone permissions location mapkit


    【解决方案1】:

    是的,这是可能的。您使用CLLocationManager 的实例(使用[locationManager startUpdatingLocation])请求使用用户位置的权限。您需要设置CLLocationManager 的代表并让它遵守CLLocationManagerDelegate protocol。具体来说,您想在您的委托上使用此方法:

    - (void)locationManager:(CLLocationManager *)manager didChangeAuthorizationStatus:(CLAuthorizationStatus)status
    

    【讨论】:

      猜你喜欢
      • 2016-11-10
      • 2013-09-22
      • 2022-06-28
      • 2017-05-30
      • 1970-01-01
      • 2015-08-13
      • 2022-08-24
      • 1970-01-01
      • 2018-01-18
      相关资源
      最近更新 更多