解决方案:
选用其中一种后台模式:
屏幕快照 2016-10-13 下午6.30.42 1.png
在 ApplicationDelegate的applicationDidEnterBackground代理中加入下面的代码:
- (void)applicationDidEnterBackground:(UIApplication *)application
{
__block UIBackgroundTaskIdentifier _bgTask;
_bgTask = [[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:^{
dispatch_async(dispatch_get_main_queue(), ^{
if (_bgTask != UIBackgroundTaskInvalid)
{
_bgTask = UIBackgroundTaskInvalid;
}
});
}];
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
dispatch_async(dispatch_get_main_queue(), ^{
if (_bgTask != UIBackgroundTaskInvalid)
{
_bgTask = UIBackgroundTaskInvalid;
}
});
});
}
搞定,下班。
网友评论