如何旋转方向?

How to rotate orientation?

当我从 UINavigationController 纵向模式切换到 UIViewController 横向模式时,我想旋转方向,但它不起作用。

我试过了

(UIApplication.shared.delegate as! AppDelegate).window!.rootViewController = playModeVc

但我可以看到下一个 viewController 的纵向模式,但我想在横向模式下看到它。当我使用

present(playModeVc, animated: true, completion: nil)

它不会释放内存。

我想在切换时释放内存viewController。我该怎么做?

我从你的问题中了解到,你想强制一个视图控制器始终以横向模式出现。

Swift3 中介绍了操作方法。将此代码添加到您想要横向显示的视图控制器:

override var supportedInterfaceOrientations: UIInterfaceOrientationMask {  
    return UIInterfaceOrientationMask.landscape  
}  

override var shouldAutorotate: Bool {  
    return false  
}