如何禁用和启用快速自动旋转? [英] How to disable and enable auto rotate on swift?

查看:61
本文介绍了如何禁用和启用快速自动旋转?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在一般设置中,我允许 Portrait 和 Landscapeleft , Landscaperight 模式.我想关闭横向模式.在 viewController 上我写了这段代码:

On general settings I allow portrait and landscapeleft , landscaperight modes. I want to turn off landscape modes. On viewController I write this code:

override func shouldAutorotate() -> Bool {

        return false

}

但是,自动旋转会忽略此功能.如何快速禁用和启用自动旋转?IOS编程

However, the auto rotation works ignoring this function. How do I disable and enable autorotation on swift? IOS programming

推荐答案

它可能是正确的代码,但不在正确的视图控制器中.例如,如果视图控制器嵌入在一个 UINavigationController 中,导航控制器仍然可以旋转,导致视图控制器仍然旋转.这真的取决于你的具体情况.

It might be the right code, but not in the right View Controller. For example, if the View Controller is embedded in a UINavigationController, the navigation controller can still rotate, causing the View Controller to still rotate. It really depends on your specific situation.

这篇关于如何禁用和启用快速自动旋转?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆