简体   繁体   中英

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. But I don't want to run said method (load the annotations) until permission is granted to use the current userLocation. Is this possible?

Yes it is possible. You request permission to use the users location using an instance of CLLocationManager (using [locationManager startUpdatingLocation] ). You need to set the delegate of your CLLocationManager and have it adhere to the CLLocationManagerDelegate protocol . Specifically, you want to use this method on your delegate:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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