重新启动应用程序时如何恢复导航控制器路径?
我正在构建一个基于导航控制器的应用程序。
我希望用户能够在重新启动应用程序时看到退出应用程序时看到的最后一个屏幕。
这就像在邮件应用程序中一样,当您在撰写邮件时按“主页”,然后当您返回邮件时,您会直接到达您正在编写的邮件。
我首先想知道什么是最好的解决方案(我认为我无法通过 NSuserdefaults 得到它)。 然后,我想知道这个解决方案是否适用于我的应用程序,考虑到在我的 rootviewcontroller 中,我在本地下载解析的数据,然后显示在多个导航控制器视图中。
I am building an app based on a navigation controller.
I would like that the user has the ability when he relaunches the app to see the last screen he saw when he quit the app.
It's exactly like in the mail app, when you push "home" while composing a mail, then when you go back to your mails you directly arrive on the mail you were writting.
I would first like to know what is the best solution (I don't think I can get that with NSuserdefaults
).
Then, I would like to know if this solution is applicable to my app, considering that in my rootviewcontroller I download data locally which I parse, then display in the multiple navigation controller views.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我刚刚解决了这个问题...不确定这是最优雅的方式...
但是,我基本上跟踪每次推送并将自己弹出到堆栈上,但我存储对象而不是视图。每次有东西被推入或弹出我的堆栈时,我都会保存它(不需要时间)。
当应用程序启动时,它会查找堆栈文件,然后执行多次推送(从加载的堆栈中弹出项目),但不会为每个项目设置动画。我的层次结构(最深的)有 4 个项目,对于用户来说,它看起来就像只是在对象上打开。
该堆栈是从根控制器的 viewDidLoad 方法中的文件加载的。
I've just solved this... not sure it is the most elegant way...
However, I basically track each push and pop myself on a stack, but I store objects rather than views. Each time something is pushed or popped off my stack I save it (takes no time).
When the application launches it looks for the stack file and then does several pushes (popping items off the loaded stack) but not animating each one. My hierarchy is (at its deepest) 4 items, and to the user it looks like it just opens on the object.
The stack is loaded from the file in the viewDidLoad method of my root controller.