以与之前不同的方向推送 UIViewController
可能是一个简单的问题,但是:
我的应用程序以纵向模式启动(并且主要是),但我有一个 ViewController,我需要将其推送到需要以横向模式打开的堆栈上。
我查了一下,发现不能使用私有API: [[UIDevice currentDevice] setOrientation:UIInterfaceOrientationLandscapeLeft];
我还发现了一系列“建议”的解决方法(包括以模态方式呈现而不是推送,以及推送 ViewController 的两个实例) 在 uinavigationcontroller 内过渡到横向旋转
但是,我确信有一定是解决这个问题的更简单的方法。如果有人知道一种压入堆栈的方法(以保留通过树的导航),使视图控制器显示为横向,请告诉我。
感谢大家的帮助,
dunc
Probably a simple question, but:
My app starts (and is mostly) in portrait mode, but I have a ViewController which I need to push onto the stack which needs to open in Landscape mode.
I've searched around and found that you can't use the private API:
[[UIDevice currentDevice] setOrientation:UIInterfaceOrientationLandscapeLeft];
I've also found a raft of "suggested" ways of tackling it (including presenting modally instead of pushing, and pushing two instances of the ViewController)
Transitioning to landscape rotation within a uinavigationcontroller
However, I'm sure there must be an easier way to tackle this. If anyone knows of a way to PUSH onto the stack (to preserve navigation through the tree), in such a way that the viewcontroller appears landscape, please let me know.
Thanks for all your help guys,
dunc
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用 UINavigationController 推送转换以不同方向呈现视图是没有意义的。导航栏/工具栏应该在哪一边?
呈现模态视图控制器是解决此问题的正确方法。如果这导致状态栏隐藏,请确保
yourModalViewController.wantsFullScreenLayout
为NO
。It makes no sense to use a
UINavigationController
push transition to present a view in a different orientation. Which way round would the navigation bar / toolbar be?Presenting a modal view controller is the right way to go about this. If this causes the status bar to become hidden, make sure
yourModalViewController.wantsFullScreenLayout
isNO
.