简体   繁体   English

MapKit,授予位置服务权限的运行方法

[英]MapKit, run method on location-service-permission being granted

I have an app with a mapkit that loads annotations during the ViewDidLoad using a loadAnnotations method. 我有一个带有Mapkit的应用程序,该应用程序使用loadAnnotations方法在ViewDidLoad期间加载注释。 But I don't want to run said method (load the annotations) until permission is granted to use the current userLocation. 但是我不想运行所述方法(加载注释),直到被授予使用当前userLocation的权限。 Is this possible? 这可能吗?

Yes it is possible. 对的,这是可能的。 You request permission to use the users location using an instance of CLLocationManager (using [locationManager startUpdatingLocation] ). 您使用CLLocationManager实例(使用[locationManager startUpdatingLocation] )请求使用用户位置的权限。 You need to set the delegate of your CLLocationManager and have it adhere to the CLLocationManagerDelegate protocol . 您需要设置CLLocationManager的委托并使其遵循CLLocationManagerDelegate协议 Specifically, you want to use this method on your delegate: 具体来说,您想在委托人上使用此方法:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM