iOS app退到后台经常被杀,重新启动体验很差

- (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 结束了");

}

你可能感兴趣的:(iOS app退到后台经常被杀,重新启动体验很差)