从后台删除后保存应用程序状态

发布于 2024-09-14 07:56:30 字数 786 浏览 3 评论 0原文

我在我的应用程序委托中使用以下函数

- (void)applicationWillResignActive:(UIApplication *)application {
    NSLog(@"applicationWillResignActive");

}


- (void)applicationDidEnterBackground:(UIApplication *)application {

    NSLog(@"applicationDidEnterBackground");

}


- (void)applicationWillEnterForeground:(UIApplication *)application {
     NSLog(@"applicationWillEnterForeground");

}


- (void)applicationDidBecomeActive:(UIApplication *)application {

      NSLog(@"applicationDidBecomeActive");

}


- (void)applicationWillTerminate:(UIApplication *)application {
   NSLog(@"applicationWillTerminate");

}

所有函数都工作正常。但是当我通过单击后台任务中的“-”红色按钮从后台删除应用程序时,然后再次打开应用程序。没有调用任何函数。我应该使用什么来代替上述所有功能..有什么想法吗?

我到底需要的是..我需要在使用“-”红色按钮从后台删除应用程序状态时保存应用程序状态,并在打开时恢复它。

I am using following functions in my App delegate

- (void)applicationWillResignActive:(UIApplication *)application {
    NSLog(@"applicationWillResignActive");

}


- (void)applicationDidEnterBackground:(UIApplication *)application {

    NSLog(@"applicationDidEnterBackground");

}


- (void)applicationWillEnterForeground:(UIApplication *)application {
     NSLog(@"applicationWillEnterForeground");

}


- (void)applicationDidBecomeActive:(UIApplication *)application {

      NSLog(@"applicationDidBecomeActive");

}


- (void)applicationWillTerminate:(UIApplication *)application {
   NSLog(@"applicationWillTerminate");

}

All functions are working fine. But When i Delete the app from the Background by clicking "-" red button in the background tasks, and again open the app. no function has been called. What should i use instead of all the above functions..have any ideas?

What exactly i need is ..i need to save the application state when it has been deleted from the background using "-" red button and restore it when ever it opened.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

倥絔 2024-09-21 07:56:30

当应用程序进入后台模式时,您应该保存应用程序的状态(-applicationDidEnterBackground)。当后台应用程序终止时,不会调用委托方法。

您应该在 iOS 应用程序编程指南

You should save the state of the application when it enters background mode (-applicationDidEnterBackground). No delegate methods are called when a background app is terminated.

You should find a lot of useful informations about this in the iOS Application Programming Guide.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文