How to make an iOS app launch in portrait mode

I have created an app that supports both landscape and portrait mode on the first view controller (the one displayed immediately after the launch screen). I can launch this app in portrait mode, rotate it to landscape and go back to portrait without any problem. But whenever the app is initially launched in landscape mode, it behaves very strangely. An easy workaround I came across is to force the app to launch in portrait mode and then let the user rotate it to landscape after launching it.

Can this be done?

I am on Xcode 8.3, iOS 10.3, the device I am testing my app on is iPad Pro 12.9 inch.

+3


source to share


1 answer


Try this in your AppDelegate func viewDidFinishLaunchingWithOptions or in your ViewDidAppear in your viewController

Swift:



let value = UIInterfaceOrientation.LandscapeLeft.rawValue
UIDevice.currentDevice().setValue(value, forKey: "orientation")

      

0


source







All Articles