سؤال

Is there a way to delay code from running until the user has answered the current location prompt? My app fetches annotations and puts them on the map. When the app launches for the first time and the user allows current location it fails to fetch any annotations because the code already ran without receiving a current location. Thanks in advance.

هل كانت مفيدة؟

المحلول

You can implement the following CLLocationManagerDelegate method:

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

and only show your annotations after that method is called. It will be called when the user accepts or rejects the current location prompt.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top