我从应用程序的一般设置中将应用程序方向锁定为纵向,就像这样:
但当我在iPad上运行我的应用程序时,它仍然会旋转!?
那我应该在哪里锁定方向呢?
为什么苹果会在设置中添加此功能,而它却不起作用!?
更新:
我尝试将此viewController实现为所有viewController的常规设置。
import Foundation
import UIKit
class GeneralViewController: UIViewController {
override func viewDidAppear(animated: Bool) {
super.viewDidAppear(animated)
let value = UIInterfaceOrientation.Portrait.rawValue
UIDevice.currentDevice().setValue(value, forKey: "orientation")
}
override func supportedInterfaceOrientations() -> Int {
return Int(UIInterfaceOrientationMask.Portrait.rawValue)
}
override func preferredInterfaceOrientationForPresentation() -> UIInterfaceOrientation {
return UIInterfaceOrientation.Portrait
}
override func shouldAutorotate() -> Bool {
return false
}
}
这张图片是我应用程序的主要navigationController中的截图。
还是不起作用!
这个东西到底怎么工作?