开发者

How to turn off location services?

开发者 https://www.devze.com 2023-01-01 11:11 出处:网络
If a user has location services on, I assign my RootController as its delegate: appDelegate.clLocationManager.delegate = self;

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消