在 iOS 中隐藏模态视图控制器(但将其保留在内存中)
我在我的应用程序中激活了一个模式视图控制器,我希望用户能够隐藏它但保留它的状态(导航堆栈等)。根据Apple的文档,dismissModalViewController会从内存中释放它。
有没有一种简单的方法可以使用另一种方法保留对其的引用?
I have a modal view controller activated in my app, and I would like for the user to be able to hide it but retain it's state (navigation stack, etc). According to Apple's docs, dismissModalViewController releases it from memory.
Is there an easy way to retain a reference to it using another method?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果你想驳回这个观点,那就不行了。您最好保留有关导航状态的任何信息,并使用它从其他视图初始化新视图。
更新
如果您需要隐藏并再次显示模态视图,我会考虑重新考虑如何使用模态视图。苹果对于如何以及为何使用模态框非常清楚。解决问题的方法有很多,但你可能只是为了让事情得到解决而让自己走上一条痛苦的道路。
Apple 视图控制器编程指南(模态视图)
Not if you are going to dismiss the view. You might be better off retaining any information about the navigation state and use that to init the new view from other views.
Update
I would consider rethinking how you are using a modal view if you need to hide it and display it again. Apple is pretty clear on how and why modals are to be used. There are ways around things, but you could just be going down a path of misery for yourself trying to keep things sorted out.
Apple View Controller Programming Guide (Modal Views)