I created a "Single View Application" project and set all options to launch and support only landscape orientation. But the app launches with its window in portrait orientation.
Console output says that the window after application:didFinishLaunchingWithOptions:
is:
{{0, 0}, {768, 1024}}
I added a standard system button to view of ViewController to illustrate that the app is landscape and not portrait, but that the window is portrait.
Because stack overflow has white background I colored the right part gray in Photoshop so you can see it:
In application:didFinishLaunchingWithOptions:
I colored the window red. It is clearly not in landscape orientation.
I have tried all the tricks I know:
1) Info.plist contains UISupportedInterfaceOrientations key with: UIInterfaceOrientationLandscapeLeft and UIInterfaceOrientationLandscapeRight
2) Info.plist contains UISupportedInterfaceOrientations~ipad key with: UIInterfaceOrientationLandscapeLeft and UIInterfaceOrientationLandscapeRight
3) Info.plist contains UIInterfaceOrientation key for initial interface orientation: UIInterfaceOrientationLandscapeRight
4) Clicked on the project in Xcode and then unchecked all portrait options and only checked the landscape options:
5) AppDelegate and the ViewController both have:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return UIInterfaceOrientationIsLandscape(interfaceOrientation);
}
- (NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight;
}
- (BOOL)shouldAutorotate {
return YES;
}
6) AppDelegate has:
- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window {
return UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight;
}
Xcode created two storyboard files. I am only testing on iPad right now. One is Main_iPad.storyboard and it shows a view controller which was in portrait. But it was only a simulated interface metric. Changed to landscape and as expected no effect.
During app launch I check UIScreen bounds and it also is clearly portrait, not landscape:
CGRect screenBounds = [[UIScreen mainScreen] bounds]; // {{0, 0}, {768, 1024}}
How can I make it launch in landscape and create a window in landscape orientation?