- (void)applicationWillEnterForeground{
[self endBackgroundTask];
}
- (void)comeToBackgroundMode{
UIApplication *application = [UIApplication sharedApplication];
self.backgroundTask = [application beginBackgroundTaskWithExpirationHandler:^{
[self endBackgroundTask];
}];
NSLog(@"计数:bgTask");
}
- (void)applicationDidEnterBackground{
[self comeToBackgroundMode];
}
- (void)endBackgroundTask
{
if (self.backgroundTask != UIBackgroundTaskInvalid) {
[[UIApplication sharedApplication] endBackgroundTask:self.backgroundTask];
self.backgroundTask = UIBackgroundTaskInvalid;
}
NSLog(@"计数:bgTask 结束了");
}
网友评论