UISplitViewController - 推送模态视图
使用 UISplitViewController 时推送模态视图的最佳实践是什么?您会从 RootViewController、DetailViewController 还是直接从应用程序委托推送?
理想情况下,我想要实现的功能是在基于某些条件加载 UISplitViewController 后立即显示模式视图控制器。
预先感谢您对此事的任何指示。
What is considered the best practise when pushing a modal view when using a UISplitViewController? Would you push from the RootViewController, the DetailViewController or directly from the Application Delegate?
Ideally the functionality I am trying to achieve is to have the modal view controller displayed as soon as the UISplitViewController is loaded based on certain conditions.
Thanks in advance for any pointers on this matter.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我试图做完全相同的事情,并且我得出了以下答案:从应用程序委托中执行此操作更简单。
在纵向模式下,RootViewController 是以一种奇怪的方式(弹出窗口)创建的,因此它不实用,应用程序委托确保您的视图在所有情况下都能正确显示。我不记得在 DetailViewController 中执行此操作有什么问题。
编辑:
application:didFinishLaunchingWithOptions:
中的实际实现是这样的:[splitViewControllerpresentModalViewController: modalViewControlleranimated: NO];
。希望这有帮助!I was trying to do the exact same thing, and I've come up with the following answer: it's simpler to do it from the App Delegate.
In Portrait mode, the RootViewController is created in a strange way (popover) so it's not practical, the Application Delegate ensures your view will show properly in all cases. I can't remember what was the issue with doing it in the DetailViewController though.
EDIT: the actual implementation in
application:didFinishLaunchingWithOptions:
is something like that:[splitViewController presentModalViewController: modalViewController animated: NO];
. Hope this helps!我实际上遇到了同样的问题并发表了这篇文章:
presentModalViewController 将新视图滑动得太远并超出屏幕顶部
基本上,当您从详细视图调用模态视图时,程序会因许多问题而爆炸在模态视图上旋转。
-=-=-=-=-=-
最重要的是,始终从根视图控制器调用模态视图。
I actually ran across the same issue and made this post:
presentModalViewController slides a new view too far up and goes above the top of the screen
Basically, when you call a modal view from the detail view, the program explodes with problems with many to do with rotating while on the modal view.
-=-=-=-=-=-
Bottom line, always call a modal view from the root view controller.