我有一个应用程序,其中某些屏幕应处于纵向模式,而某些屏幕应处于横向模式。例如,主菜单为人像并且有一个摄像头按钮。相机只能在横向使用。我正在使用Storyboard和NavigationController。我应该在哪里以及该怎么做?
我已经尝试包括
shouldAutorotate() -> Bool {return false or return true}
都不起作用。我已经设定了
supportedInterfaceOrientation
对于我拥有的每个ViewController。没有任何帮助。我需要一个可以调用的功能来强制屏幕进入横向/纵向模式。
在您的ViewDidLoad中(或所需位置)使用此行代码。
斯威夫特1 UIDevice.currentDevice().setValue(UIInterfaceOrientation.LandscapeLeft.rawValue, forKey: "orientation")
3分钟前在Swift 1.2 Xcode 6.3中测试
迅捷3(感谢Fa.Shapouri)
UIDevice.current.setValue(UIInterfaceOrientation.landscapeLeft.rawValue, forKey: "orientation")
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句