Locationservice Indicator stays “on”

我的梦境 提交于 2019-11-28 23:53:37

I had the same problem - app leaving the location indicator on in the status bar.

My problem turned out to be that I had originally called the 'startMonitoringSignificantLocationChanges' method of CCLocationManager thinking that would give rough location info that I could up the resolution on when I really needed it.

Unfortunately once an app has called that method once, even if you then delete the app and re-install it it will always re-show the icon in the status bar until the app calls 'stopMonitoringSignificantLocationChanges' on CCLocationManager to unregister itself from the system - complete pain as I have to leave that code in until it has sorted itself out on the several people who were testing my app for me.

So if you get that icon stuck on with your app make sure you've matched any calls to 'startMonitoringSignificantLocationChanges' with a stop call.

if you started your location manager job with

[MyLocationManagerInstance startMonitoringForSignificantLocationChanges];

then you need to stop it with:

[MyLocationManagerInstance stopMonitoringForSignificantLocationChanges];

If you force the termination of the application, applicationWillTerminate isn't called, as, for the OS point of view, it appears as a SIGKILL.

I met a similar problem. The problem only happens on iPhone4, but works perfect on my 3GS. After looking into my code, I found that in my startUpdatingLocation method I used startUpdatingLocation and startMonitoringForRegion services, however, in my stopUpdatingLocation method I just stop updatingLocation service. I fixed this issue by turning off MonitoringForRegion as well.

#pragma mark -
#pragma mark Location methods
- (void)startUpdatingLocation
{

    [self.locationManager startUpdatingLocation];

    [self.locationManager startMonitoringForRegion:desRegion desiredAccuracy:50.0f];
}

- (void)stopUpdatingLocation
{
    [self.locationManager stopUpdatingLocation];

        //  !!!: fix location service indicator stuck issue
    [self.locationManager stopMonitoringForRegion:desRegion];
}

Ok, problem solved. The indicator will stay on until a new location is found. Then if everything else is correct, the indicator turns off.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!