5
votes

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.

2
Are you setting your UIViewController as rootViewController?Nitheesh George
When you are designing app for both the orientations you must work for Landscape orientation as well so that a user opening app in Landscape can also use app without any issue.Suraj Mirajkar
do you have all splash screens for landscape and portrait? Sometimes it makes this.kocakmstf
The root viewcontroller is a tabcontroller.thpitsch

2 Answers

1
votes

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
        }
    }
-2
votes

Click the project name in project navigator. Then go to general and to deployment options section choose your preferred device orientation

enter image description here