【发布时间】:2018-09-05 02:10:28
【问题描述】:
【问题讨论】:
标签: ios objective-c uiviewcontroller landscape device-orientation
【问题讨论】:
标签: ios objective-c uiviewcontroller landscape device-orientation
简短的回答是你不能因为根据苹果文档here
系统与视图控制器支持的方向相交 应用程序支持的方向(由 Info.plist 确定 文件或应用程序委托的 application(_:supportedInterfaceOrientationsFor:) 方法)和 设备支持的方向来确定是否旋转。
要实现您所需要的,您也应该将允许的方向设置为横向,然后在您的视图控制器中实现以下内容以允许纵向或横向(或两者):
override var supportedInterfaceOrientations: UIInterfaceOrientationMask {
return UIInterfaceOrientationMask.portrait//or UIInterfaceOrientationMask.landscape
}
然后要强制特定方向,您可以将方向设置为 UIDevice:
UIDevice.current.setValue(UIInterfaceOrientation.landscapeLeft.rawValue, forKey: "orientation")
【讨论】: