简体   繁体   English

如何在iOS 5中管理状态保存和还原

[英]How to manage state preservation and restoration in iOS 5

I've been having a look at the "State Preservation and Restoration" section in iOS App Programming Guide , and the process described there seems to be available only from iOS 6. Since I need to make my app compatible from iOS 5, I don´t find a, let's say, equivalent way to handle this. 我一直在看《 iOS App编程指南 》中的“状态保存和还原”部分,并且那里描述的过程似乎仅在iOS 6中可用。由于我需要使我的应用程序与iOS 5兼容,所以我不这样做。不能找到一种等效的方法来处理此问题。

To provide a certain scenario, I have an UINavigationController where I push a sequence of view controllers where I request user input. 为了提供某种方案,我有一个UINavigationController ,在其中推送了一系列视图控制器,并在其中请求用户输入。 It is like a step-by-step form, and data provided is not finally saved until the last step is completed. 就像分步表单一样,所提供的数据直到最后一步完成后才最终保存。 I'd want to temporarily save the inputs as the user provides them, just in case the app terminates or goes to background, to show them again when the user returns to the app, in order to prevent him from having to enter again the data that he already provided. 我想在用户提供输入时临时保存输入,以防应用终止或进入后台,以便在用户返回到应用时再次显示它们,以防止他不得不再次输入数据他已经提供的 This may be a common scenario in an iOS app, I guess. 我想这可能是iOS应用中的常见情况。

I was thinking about saving temp data to files, but I don't know if this is the unique/best way in iOS 5. Any help or any example/tutorial/document dealing with this issue? 我当时正在考虑将临时数据保存到文件中,但是我不知道这是否是iOS 5中唯一/最佳的方法。是否有任何帮助或任何示例/教程/文档来解决此问题?

Thanks! 谢谢!

Prior to iOS 6, you had to save/restore state yourself by overriding functions like applicationDidEnterBackground and applicationWillTerminate in your application delegate. 在iOS 6之前,您必须通过覆盖applicationWillTerminate程序委托中的applicationDidEnterBackgroundapplicationWillTerminate类的功能来保存/恢复状态。

You'll learn everything you need by searching on stackoverflow or google for those functions names, but in short you had to write a custom solution (typically saving all the info you need to a restore again to a file). 您将通过在stackoverflow或google上搜索这些函数名称来学习所需的一切,但是总之,您必须编写一个自定义解决方案(通常将所需的所有信息保存到文件中再次还原)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM