gpt4 book ai didi

ios - 如何在 iPhone 中管理多任务

转载 作者:行者123 更新时间:2023-11-28 19:20:53 25 4
gpt4 key购买 nike

当我点击设备上的主页按钮时。这是我委托(delegate)的一部分:

- (void)applicationWillResignActive:(UIApplication *)application
{
NSLog(@"resign active");
//[[NSThread mainThread] cancel];
}
- (void)applicationDidEnterBackground:(UIApplication *)application
{
NSLog(@"enter background");
//[[NSThread mainThread] cancel];
}

- (void)applicationWillEnterForeground:(UIApplication *)application
{
NSLog(@"enter foreground");
//[[NSThread mainThread] cancel];
}
- (void)applicationWillTerminate:(UIApplication *)application
{
NSLog(@"terminate");
//[[NSThread mainThread] cancel];
}

我使用 NSLog 来了解当我单击主页按钮时调用了哪个方法。这是在控制台中的输出。

2012-01-20 15:55:55.853 MyApp[5955:11f03] enter background
2012-01-20 15:55:55.855 MyApp[5955:11f03] terminate
Program ended with exit code: 0

因此,当我在后台单击应用程序(单击两次主页按钮)时,它会再次启动,显示第一张图片,然后是我的第一个 uiviewcontroller。

我可以通过哪种方式解决它,并从用户单击主页按钮时位于顶部的 uiviewcontroller 恢复应用程序?

最佳答案

检查您的 info.plist 文件并确保未选中“应用程序不在后台运行”。

下图显示了处于“打开”状态的选项,因此当用户按下主页按钮时,应用程序实际上已完成。

info.plist configuration

这就是Apple describes that option :

UIApplicationExitsOnSuspend

UIApplicationExitsOnSuspend (Boolean - iOS) specifies that the application should be terminated rather than moved to the background when it is quit. Applications linked against iOS SDK 4.0 or later can include this key and set its value to YES to prevent being automatically opted-in to background execution and application suspension. When the value of this key is YES, the application is terminated and purged from memory instead of moved to the background. If this key is not present, or is set to NO, the application moves to the background as usual.

This key is supported in iOS 4.0 and later.

关于ios - 如何在 iPhone 中管理多任务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8943384/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com