iOS 6保存/恢复应用程序状态功能 [英] iOS 6 Saving/Restoring app state feature

查看:109
本文介绍了iOS 6保存/恢复应用程序状态功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在iOS 6上使用新的保存/恢复应用状态功能,但是如果我杀了应用程序以便它不会恢复应用程序状态,则不调用(application:shouldRestoreApplicationState :)方法,但如果我我从它调用的调试器中运行它。

I'm trying to use the new Saving/Restoring app state feature on iOS 6, but (application:shouldRestoreApplicationState:) method is not called if I killed the app so it doesn't restore the app state, but If I'm running it from the debugger it gets called.

当我在plist中添加(Application不在后台运行)并将其设置为YES时,它有效不想把它设置为YES。我想知道是否有人在没有将(应用程序不在后台运行)设置为YES的情况下工作。

It worked when I added (Application does not run in background) in the plist and set it to YES, I don't want to set it to YES though. I was wondering if anyone got it working without setting the (Application does not run in background) to YES.

推荐答案

从< a href =https://developer.apple.com/library/ios/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/StrategiesforImplementingYourApp/StrategiesforImplementingYourApp.html#//apple_ref/doc/uid/TP40007072-CH5-SW31\"rel =nofollow noreferrer> Apple文档:


当用户强制退出应用程序时,系统会自动删除应用程序的保留状态。在应用程序被杀死时删除保留的状态信息是一种安全预防措施。 (作为安全预防措施,如果应用程序在启动期间崩溃两次,系统也会删除保留状态。)如果要测试应用程序恢复其状态的能力,则不应使用多任务栏在调试期间终止应用程序。相反,使用Xcode杀死应用程序或通过安装临时命令或手势以按需调用退出来以编程方式终止应用程序。

The system automatically deletes an app’s preserved state when the user force quits the app. Deleting the preserved state information when the app is killed is a safety precaution. (As a safety precaution, the system also deletes preserved state if the app crashes twice during launch.) If you want to test your app’s ability to restore its state, you should not use the multitasking bar to kill the app during debugging. Instead, use Xcode to kill the app or kill the app programmatically by installing a temporary command or gesture to call exit on demand.

来自经验,最简单的方法是通过按主页按钮(或模拟器的Command + Shift + H)将您的应用程序置于后台。然后使用Xcode停止按钮。正如文档建议的那样,调试退出手势也可以。

From experience, the easiest way is to put your app into the background by pressing the home button (or Command+Shift+H for the simulator). Then use the Xcode stop button. As the docs suggests, a debug exit gesture also works.

更新:

我找到了一个小工作。该应用程序将其状态保存在库/保存的应用程序状态/ [捆绑ID] - [应用程序名称] .savedState / data.data中。

I found a small work around. The app saves its state in Library/Saved Application State/[Bundle ID]-[App Name].savedState/data.data.

使用模拟器时,您可以复制此文件,并在要恢复到该特定状态的任何时候将其删除。

When using the simulator, you can copy this file and drop it in anytime you want to restore to that specific state.

同样,在设备上,您可以从组织者生成.xcappdata存档。然后,当您要从该已保存状态还原时,可以上载.xcappdata存档。

Similarly, on a device you can generate a .xcappdata archive from the organizer. Then, you can upload the .xcappdata archive when you want to restore from that saved state.

这篇关于iOS 6保存/恢复应用程序状态功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆