如何在Swift中强制设备旋转? [英] How to force device rotation in Swift?

查看:98
本文介绍了如何在Swift中强制设备旋转?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在Swift中强制设备旋转.
我读过,这段代码应该可以用,但不能用:
let value = UIInterfaceOrientation.LandscapeRight.rawValue UIDevice.currentDevice().setValue(value, forKey: "orientation")

I want to force a device rotation in Swift.
I've read, that this code is supposed to work but it doesn't:
let value = UIInterfaceOrientation.LandscapeRight.rawValue UIDevice.currentDevice().setValue(value, forKey: "orientation")

那是旧版本还是为什么不起作用?

Is that maybe an old version or why isn't it working?

推荐答案

唯一支持的强制设备旋转的方法是执行全屏显示视图控制器,其支持的方向仅限于一个( s)您想要的.

The only supported way to force a device rotation is to do a fullscreen presented view controller whose supported orientations are limited to the one(s) you want.

关于该主题的任何其他骇客知识(例如,在您提供的代码中设置设备方向),都是错误的,不受支持.

Whatever other hacky stuff you may read on this topic (such as setting the device orientation in the code you gave) is wrong and unsupported.

这篇关于如何在Swift中强制设备旋转?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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