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.
iOS app starts in landscape mode
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.
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. :-D –
Gaige
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 go to your supported device orientations and check if you have portrait mode selected
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
if you only support Landscape, write code
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return UIInterfaceOrientationIsLandscape(interfaceOrientation);
}
it work for me.
Maybe you already had set the
UIInterfaceOrientation
as Item 0 inside Supported interface orientation
. Doesn't look like this matches with the asked question –
Control 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.
© 2022 - 2024 — McMap. All rights reserved.