簡體   English   中英

始終以縱向顯示視圖控制器[iOS]

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM