iOS app starts in landscape mode
Asked Answered
H

4

12

I have a strange problem. My app keeps starting in landscape mode. If I open it in simulator it rotates to landscape mode automatically. When I start it on iPhone it firstly starts in landscape mode and then shortly after it rotates to correct position. I have set "Initial interface orientation" in .plist to portrait, but that changed nothing.

Howzell answered 9/2, 2012 at 12:56 Comment(0)
M
31

I had the same problem. If you go to your Supported Interface Orientations you'll see Item 0 ... Item 1 ...

And so on. If you edit this list so that Portrait (bottom home button) is the first item in the list then your app will open in portrait mode. You can still support other orientations as items 1 thru 3.

Midriff answered 13/2, 2012 at 19:39 Comment(5)
Thanks! It's so simple, but I have spent many hours with this.Howzell
Thanks, this just solved me getting a little annoyed with my app. :-DGaige
Note that while this is the correct fix it is a regression on Apple's part. From the docs: This method is an override that replaces the default behavior by returning YES for the UIInterfaceOrientationPortrait, UIInterfaceOrientationLandscapeLeft, and UIInterfaceOrientationLandscapeRight orientations.Boltrope
Thanks!. I've been trying to imagine what was wrong for a long time.Immersionism
This didn't work for me on iOS 8 (iPad Mini). What I did was -(BOOL) shouldAutorotate { return YES; } - (NSUInteger)supportedInterfaceOrientations { return UIInterfaceOrientationMaskPortrait; }. It prevents your app from going to landscape mode during launch.Artemus
Y
0

go to your supported device orientations and check if you have portrait mode selected

Yates answered 9/2, 2012 at 13:36 Comment(2)
All modes are selected (in fact I need them all).Howzell
and what about the mehod - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { // Return YES for supported orientations return YES; }Yates
S
0

cancel orientations in plist

if you only support Landscape, write code

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return UIInterfaceOrientationIsLandscape(interfaceOrientation);
}

it work for me.

Synchrocyclotron answered 3/4, 2013 at 2:10 Comment(1)
Maybe you already had set the UIInterfaceOrientation as Item 0 inside Supported interface orientation. Doesn't look like this matches with the asked questionControl
R
0

In XCode 6.4, I just unchecked all 4 of the device orientations and reselected them starting with portrait in the Deployment Info for the Target app. Apparently the order that they are checked here controls the order of the values in the plist file.

Ramayana answered 25/8, 2015 at 18:53 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.