My app is designed to work in Portrait and in landscape orientations. Starting with iOS 8 there is a problem starting the app if the device is held in landscape orientation. The UI is simply not correct initialized.
My Users have to close the app and start again while holding the device in portrait.
How can I arrange that the app is always launching in portrait mode without locking it to this mode? After this the user should be allowed to change to all four orientations.
In my view controller shouldAutorotate returns true, and supportedInterfaceOrientations returns all.
Heres a solution that worked for me on ios 11, my app supports Portrait and landscape but the initial view has tab bar that must be in portrait always. Set orientation lock and create a Utility that you should be executed inside didFinishLaunchingWithOptions like this :
AppUtility.lockOrientation(.portrait)
func application(_ application: UIApplication, supportedInterfaceOrientationsFor window: UIWindow?) -> UIInterfaceOrientationMask {
return self.orientationLock
}
struct AppUtility {
static func lockOrientation(_ orientation: UIInterfaceOrientationMask) {
if let orientationDelegate = UIApplication.shared.delegate as? AppDelegate {
orientationDelegate.orientationLock = orientation
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With