我正在設計一個通用應用程序,我喜歡僅支持iPhone和iPad的肖像。但我需要iPad來支持經常和顛倒的縱向。如何在縱向模式下支持iPad的180度變體?
爲iPhone和iPad在info.plist
爲Portrait (top home button)
和Portrait (bottom home button).
繼AppDeleagte.swift
var shouldSupportAllOrientation = false
func application(_ application: UIApplication, supportedInterfaceOrientationsFor window: UIWindow?) -> UIInterfaceOrientationMask {
if (shouldSupportAllOrientation == true){
return UIInterfaceOrientationMask.all
}
return UIInterfaceOrientationMask.portrait
}
所以我組支持的接口方位ViewController.swift
override func viewWillAppear(_ animated: Bool) {
let appdelegate = UIApplication.shared.delegate as! AppDelegate
appdelegate.shouldSupportAllOrientation = false
let value = UIInterfaceOrientation.portraitUpsideDown.rawValue
UIDevice.current.setValue(value, forKey: "orientation")
}
繼當我轉動我的iPad在模擬器中顛倒過來,它仍然是upsi減少並且不旋轉180度。我哪裏錯了?
我沒有檢查倒置,但它仍然無法正常工作。 – Coder221