【发布时间】:2015-08-06 09:35:15
【问题描述】:
我像这样将应用程序方向从一般应用程序设置锁定为纵向
但是当我在 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
}
}
这张图片取自我应用的主导航控制器。
还是不行!
这东西到底是怎么工作的?
【问题讨论】: