Landscape View

Discussion in 'iOS Programming' started by nashyo, Mar 24, 2012.

  1. nashyo, Mar 24, 2012
    Last edited by a moderator: Mar 24, 2012

    nashyo macrumors 6502

    nashyo

    Joined:
    Oct 1, 2010
    Location:
    Bristol
    #1
    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?
     
  2. ArtOfWarfare, Mar 24, 2012
    Last edited: Mar 24, 2012

    ArtOfWarfare macrumors 604

    ArtOfWarfare

    Joined:
    Nov 26, 2007
    #2
    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
     
  3. Mark FX macrumors regular

    Mark FX

    Joined:
    Nov 18, 2011
    Location:
    West Sussex, UK
    #3
    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
     
  4. xStep macrumors 68000

    Joined:
    Jan 28, 2003
    Location:
    Less lost in L.A.
    #4
    I'm also wondering if this request is specific to an iPad or iPhone/iPod device?
     
  5. nashyo thread starter macrumors 6502

    nashyo

    Joined:
    Oct 1, 2010
    Location:
    Bristol
    #5
    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?
     

Share This Page