Is there a way to always present a view controller from portrait? For example, if I am in landscape mode with the home button to the left, and the view controller is presented from the left side. It's always being presented from the bottom relative to the view
//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()
})
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.