the*_*ter 3 iphone sleep screen userlocation
我正在制作一个使用用户位置的iPhone应用程序,但是我注意到当iPhone屏幕休眠/关闭时,手机仍在使用用户位置.那么是否有一个功能可以告诉我什么时候屏幕睡觉所以我可以stopUpdatingLocation?
@interface RideauAppDelegate : NSObject <UIApplicationDelegate, UITabBarControllerDelegate> {
UIWindow *window;
UITabBarController *tabBarController;
}
@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) IBOutlet UITabBarController *tabBarController;
@end
Run Code Online (Sandbox Code Playgroud)
您可以使用:
- (void)applicationWillResignActive:(UIApplication *)application {
[[[self.tabBarController.viewControllers objectAtIndex:0] locationManager] stopUpdatingLocation];
//if it is your first VC, if not change objectAtIndex: to the correct one
}
Run Code Online (Sandbox Code Playgroud)