如何在一个视图控制器上旋转屏幕?

发布于 2025-01-16 04:33:31 字数 436 浏览 2 评论 0原文

我的应用程序正在开发为混合应用程序。

我的问题是如何从当前视图控制器切换到垂直模式?

我的主视图控制器基本上处于垂直模式(固定),如果需要,我需要将其更改为水平模式。

覆盖此功能并将其修复为纵向模式。

override var supportedInterfaceOrientations: UIInterfaceOrientationMask {
          return .portrait 
}

无法通过以下功能更改水平模式。

let value = UIDeviceOrientation.landscapeRight.rawValue
    UIDevice.current.setValue(value, forKey: "orientation")

你能帮助我吗?

My app is under development as a hybrid app.

My question is how do I switch from the current view controller to vertical mode?

My main view controller is basically in vertical mode (fixed), and if necessary, I need to change it to horizontal mode.

Override this function and fix it in portrait mode.

override var supportedInterfaceOrientations: UIInterfaceOrientationMask {
          return .portrait 
}

Horizontal mode cannot be changed through the function below.

let value = UIDeviceOrientation.landscapeRight.rawValue
    UIDevice.current.setValue(value, forKey: "orientation")

Can you help me?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文