How to turn off location services?
If a user has location services on, I assign my RootController as its delegate:
appDelegate.clLocationManager.delegate = self;
where appDelegate is an instance of my application delegate, which is where I have the location services instance. clLocationManager is an instance of CLLocationManager. If I di开发者_如何学Cscover the user is outside of a certain region, I want to disable location service delegates. I do this:
appDelegate.clLocationManager.delegate = nil;
But this method still fires:
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
Is there another way to disable location services or at least keep its methods from firing?
Yes, you need to tell it to stop updating location:
[appDelegate.clLocationManager stopUpdatingLocation];
After that you can also release it.
See the documentation for details.
精彩评论