I have an application with four tabs. Two of the tabs use location updates and other two don’t require GPS. I use following code to turn off the location updates when the view is about to disappear
- (void)viewWillDisappear:(BOOL)animated {
[self.locationManager stopUpdatingLocation];
}
This seems to work when I change tabs. The puzzle is that when user hits the home button while in the tabs which do not require location information then GPS is turned off. However if the user hits the home button while in one of the tabs that is using location updates then the GPS is left turn on. I think it is because “viewWillDisappear” is never called when the user hits the home button.. Am I right in that assumption, any suggestion on how to fix this problem.
Soofi
Add the “UIBackgroundModes” key to your -Info.plist but don’t specify any values, that should ensure location services are not used in the background.