What is the best way to restore the state of ViewController

余生长醉 提交于 2019-12-01 09:45:18

问题


I would like to ask some suggestion about how to restore a viewControllers state. Like in the app called "Pic Collage" when you create a card and save it and later restore it.


回答1:


If you really want to learn about state preservation, see WWDC 2012 video, Saving and Restoring Application State on iOS.

But, it's also just as likely that the app in question is simply saving the model data (the object model that represents this card) in persistent storage, and when the app re-starts, it simply loads that model data again. There are a whole bunch of possible technologies for persistent storage ranging from Core Data (robust, but a little complicated) to plists (simple, but less sophisticated). There are tons other options (archives and serialization, SQLite, JSON, etc.), but I'd rather not cloud the issue further.

I'd suggest you familiarize yourself with some of these technologies, work through a few demonstrations, and come back if you have additional questions. But this question is too broad to get into specific answers at this point.




回答2:


If you are supporting iOS 6 and above, take a look at State Preservation and Restoration. Even if you have to support older versions of iOS the documentation will guide you on when and how restoration can be achieved and the things you need to consider.



来源:https://stackoverflow.com/questions/18166399/what-is-the-best-way-to-restore-the-state-of-viewcontroller

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!