我有一个以纵向 View 设计的 View Controller 。我有另一个在横向 View 中设计的 View Controller (在 Storyboard 中)。在我的第一个 View Controller (纵向 VC)上,我有一个按钮可以将您带到横向 VC。当您单击按钮时,横向 View Controller 最初以纵向 View 显示,并且在旋转之前不会改变。我想让这个横向 View Controller 自动显示在横向中,而无需旋转它。 我一直在快速编码,但没有运气。在我的 plist 菜单中,我启用了所有方向。 任何帮助都会很棒。
请您参考如下方法:
您应该在 viewDidLoad 的 second viewcontroller(设计为横向)中添加它
它在 swift3 中:
let value = UIInterfaceOrientation.landscapeLeft.rawValue
UIDevice.current.setValue(value, forKey: "orientation")
UIViewController.attemptRotationToDeviceOrientation()
希望对你有帮助:)
