我想设置UIWebview
总是在后台运行。
UIWebview
当 iPhone 进入 ' ' 时不工作applicationDidEnterBackground
。所以我想UIWebview
总是在后台运行。可能吗?
问问题
1620 次
1 回答
2
每个应用程序都可以在后台继续执行大约 10 分钟,然后才会终止。只有某些应用程序可以在后台继续执行,例如音频/gps/蓝牙等相关应用程序。您可以在此处了解更多信息。
以下代码示例来自应用程序文档,可以帮助您入门 -
- (void)applicationDidEnterBackground:(UIApplication *)application
{
bgTask = [application beginBackgroundTaskWithExpirationHandler:^{
// Clean up any unfinished task business by marking where you.
// stopped or ending the task outright.
[application endBackgroundTask:bgTask];
bgTask = UIBackgroundTaskInvalid;
}];
// Start the long-running task and return immediately.
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
// Do the work associated with the task, preferably in chunks.
[application endBackgroundTask:bgTask];
bgTask = UIBackgroundTaskInvalid;
});
}
于 2012-10-29T00:59:00.933 回答