我从这样的常规应用设置中将应用方向锁定为纵向
但是当我在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。
还是没用!
这东西到底是怎么工作的?
您不需要额外的代码,我正在使用Xcode 7.0.1,我注意到当我将屏幕方向锁定为仅纵向时,它仅在iPhone中锁定,也要将其锁定在iPad中,您需要从设备中选择iPad (而不是Universal)并检查人像,然后取消选中其他人,然后再次将设备返回Universal,因为我发现Universal仅反映在iPhone中,这可能是Xcode中的某种错误。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句