程序切入后台后,再 杀死, 调用terminal 代理

2017-11-17  本文已影响11人  i诺离
-(void)applicationDidEnterBackground:(UIApplication *)application {
    __block UIBackgroundTaskIdentifier _bgTask;
    _bgTask = [[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:^{
        dispatch_async(dispatch_get_main_queue(), ^{
            if (_bgTask != UIBackgroundTaskInvalid)
            {
                [[UIApplication sharedApplication] endBackgroundTask:_bgTask];
                _bgTask = UIBackgroundTaskInvalid;
            }
        });
    }];
}
上一篇下一篇

猜你喜欢

热点阅读