Dav*_*id 2 orientation ipad screen-rotation ios swift
我有以下代码可以在iPhone上正常运行,但不能在iPad上运行。它应该仅在此ViewController上锁定方向的横向方向并禁用自动旋转(对于整个应用程序不禁用-请勿更改project / info.plist文件中的属性):
override var shouldAutorotate : Bool {
return false
}
Run Code Online (Sandbox Code Playgroud)
并在viewDidLoad():
let landscapeValue = UIInterfaceOrientation.landscapeRight.rawValue
UIDevice.current.setValue(landscapeValue, forKey: "orientation")
Run Code Online (Sandbox Code Playgroud)
如何将方向锁定为横向并禁用当前ViewController的旋转(就像它已经在iPhone上正常运行一样)?
我的规格:
XCode-9.1内部版本9B55
迅捷-4.0.2
在iPad Air上进行了测试-iOS 10.3.3
| 归档时间: |
|
| 查看次数: |
873 次 |
| 最近记录: |