2
我searching
,我怎么只能改变orientation
到LandScape
模式spefic view controller
当Device Orientation
项目settings
设置为Portrait
。没有得到任何成功的结果。所以最后我找到了一个办法。更改方向只针对特定视图控制器在IOS SWIFT 2.3和SWIFT 3
这是项目设备的方向看起来像....
在SWIFT 2.3添加下面的方法
override func shouldAutorotate() -> Bool {
return false
}
override func supportedInterfaceOrientations() -> UIInterfaceOrientationMask {
return UIInterfaceOrientationMask.LandscapeLeft
}
override func preferredInterfaceOrientationForPresentation() -> UIInterfaceOrientation {
return UIInterfaceOrientation.LandscapeLeft
}
为SWIFT 3.0做像下面....
override var shouldAutorotate: Bool {
return false
}
override var supportedInterfaceOrientations: UIInterfaceOrientationMask {
return .landscapeLeft
}
override var preferredInterfaceOrientationForPresentation: UIInterfaceOrientation {
return .landscapeLeft
}
注意:如果您从一个视图导航到另一个视图控制器而没有导航控制器,这将工作正常。
更多的看到这个小视频教程:change device orientation for specific view controller in ios
如果任何人有更好的方式来做到这一点或意见,希望你的回答或评论在这里。 thanx。
除了答案添加全局varibale - 即使你与一些自定义过渡样式模式存在,布局方向更改将无法正常工作。 –