在纵向状态下强制旋转 UIViewController

Force rotate UIViewController in Portrait status

在这种环境下 (修复项目配置中的支持方向为纵向)

你能在 Landscape 中显示特定的 UIViewController 吗?

简短的回答是你不能,因为根据 Apple 文档 here

The system intersects the view controller's supported orientations with the app's supported orientations (as determined by the Info.plist file or the app delegate's application(_:supportedInterfaceOrientationsFor:) method) and the device's supported orientations to determine whether to rotate.

要实现您的需要,您还应该将允许的方向设置为横向,然后在您的视图控制器中实现以下内容以允许纵向或横向(或两者):

override var supportedInterfaceOrientations: UIInterfaceOrientationMask {
    return UIInterfaceOrientationMask.portrait//or UIInterfaceOrientationMask.landscape
  }

然后要强制特定方向,您可以将方向设置为 UIDevice:

UIDevice.current.setValue(UIInterfaceOrientation.landscapeLeft.rawValue, forKey: "orientation")