iOS Landscape View

nashyo

macrumors 6502
Original poster
Oct 1, 2010
299
0
Bristol
The following method has caused a problem that I cannot fix. My splash screen status bar is landscape (returns to portrait at rootViewController).

Code:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    if (interfaceOrientation == UIInterfaceOrientationLandscapeRight) return YES;
    return NO;
}
To find a solution, I have literally disconnected my whole storyboard from the root view controller, set up a new root view controller by dragging a 'view controller' object from the object library onto the storyboard, and run the App on my phone and simulator, and still the same thing.

Is there a setting in plist that I need to change? I have no idea why this change happened, but I cannot get my app to launch the splash screen with the status bar in portrait mode.

I have tried 'initial view is portrait' property in plist, to no avail.

Please help, i'm having a nightmare. Is this a bug?
 
Last edited by a moderator:

ArtOfWarfare

macrumors G3
Nov 26, 2007
8,565
3,978
I'm confused...

What is happening right now?

What do you want to have happen?

Edit: If I had to guess, you might want to change

UIInterfaceOrientationLandscapeRight to UIInterfaceOrientationPortrait
 
Last edited:

Mark FX

macrumors regular
Nov 18, 2011
119
8
West Sussex, UK
Like ArtOfWarfare I'm not sure what your trying to achieve, but if it is your
intention to have the view only show in landscape right orientation, then this
is how you would do that.

Code:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)io
{
    return (io == UIInterfaceOrientationLandscapeRight);
}
But if you wanted to have either of the landscape orientations available, and
start the view in the right side orientation, then you would do it like this.

Code:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)io
{
    return (io == UIInterfaceOrientationLandscapeRight || UIInterfaceOrientationIsLandscape(io));
}
hope this is of some help.

Regards Mark
 

nashyo

macrumors 6502
Original poster
Oct 1, 2010
299
0
Bristol
Hi,

My App is for iPhone only at this point.

I solved the problem by starting a new project and developing the storyboard again from the ground up. I still use the same code, so I'm confused about what triggered this odd behaviour.

I lock one of my views in landscape and the status bar adjusts to landscape mode accordingly. When dismissing this modal view, the view and status bar suitably returns to portrait mode. I have no idea why the status bar was misbehaving before. Maybe a property had changed somewhere by accident. I have no idea.

However, I've noticed this problem again in my App in a different view where a UIWebView opens a pdf file. Specifically, the event that triggers the status bar change is dictionary. When I select a word in a pdf file and select 'define' the view segues modally to a dictionary view and shows the definition. At this point the status bar changes to landscape, even tho the view and it's content are portrait. After dismissing the dictionary definition modal view, the status bar remains in landscape mode, when the view is portrait. The status bar remains this way until I navigate to the view I just mentioned that forces landscape mode. After leaving this view, the status bar returns to portrait mode, just fine.

The dictionary feature is pre-programmed in the UIWebView class, so I don't know what method I need to call to ensure the status bar does not enter landscape mode. I don't know what is triggering this activity. It seems like a bug. Has anyone seen anything similar?