当我在plist中添加(应用程序不在后台运行)并将其设置为YES时,它工作,我不想将其设置为YES.我想知道有没有人在没有设置(应用程序不在后台运行)中工作.
解决方法
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停止按钮.正如文档所示,调试退出手势也起作用.
更新:
我发现了一个小小的工作.该应用程序将其状态保存在Library / Saved Application State / [Bundle ID] – [App Name] .savedState / data.data中.
使用模拟器时,您可以复制此文件并将其放回任何要恢复到该特定状态的任何时间.
类似地,在设备上,您可以从管理器生成.xcappdata存档.然后,当您要从保存的状态恢复时,您可以上传.xcappdata存档.