[英]Always present a view controller from portrait [iOS]
有沒有一種方法可以始終顯示縱向視圖控制器? 例如,如果我處於風景模式,而主頁按鈕位於左側,則視圖控制器從左側顯示。 總是相對於視圖從底部顯示
//When button is pressed
let viewController = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "viewContoller") as! CustomViewController
self.present(viewController, animated: true, completion: nil)
//App delegate
func application(_ application: UIApplication, supportedInterfaceOrientationsFor window: UIWindow?) -> UIInterfaceOrientationMask {
return .all
}
override func viewDidLoad() {
super.viewDidLoad()
UIView.performWithoutAnimation({
let value = UIInterfaceOrientation.portrait.rawValue
UIDevice.current.setValue(value, forKey: "orientation")
UIViewController.attemptRotationToDeviceOrientation()
})
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.