2

I searched for other existing posts, but none of them satisfied my requirements.

Here is the problem i face,

  1. My app supports both the Modes , landscape and portrait.
  2. But my first screen only supports Landscape , so the app must start in Landscape.
  3. I have set supported Orientation to all the 4 options
  4. I have set the Initial interface orientation to Landscape (left home button)
  5. In the view controller of the first screen i am defining the below

-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation

    {
        return (interfaceOrientation != UIInterfaceOrientationPortrait);
    }

And when i start the app the simulator always opens in Portrait and my view is all messed up in the portrait mode , since it is designed only for the landscape. After the switch to the Landscape, the device remains in this mode.

can anyone help me with the solution to avoid this ?

Thanks Naveen

EDITED :

This info may be helpful , The problem is faced only when i hold the device in Portrait and then launch the app.

Its not the duplication of this question, Landscape Mode ONLY for iPhone or iPad

Landscape Mode ONLY for iPhone or iPad

I do not want my app to be only in Landscape , i want only the first screen of my app to be only in Landscape.

Community
  • 1
  • 1
RVN
  • 4,157
  • 5
  • 32
  • 35
  • Try changing your simulator to landscape before launching it *from the home-screen* instead of from Xcode. Try launching it on an actual device, that is the gold standard for how it will launch. – fearmint Feb 15 '12 at 14:31
  • 1
    The unhelpful (but how Apple would expect it) response is: make the first screen work in all orientations. – Stephen Darlington Feb 15 '12 at 14:33
  • possible duplicate of [Landscape Mode ONLY for iPhone or iPad](http://stackoverflow.com/questions/2647786/landscape-mode-only-for-iphone-or-ipad) – p.campbell Feb 15 '12 at 14:37
  • You run the risk of Apple not approving your app if you don't support all orientations (at all times) on ipad apps. – ader Feb 15 '12 at 15:17

3 Answers3

5

I did some experimenting with an app I'm working on that has the same requirements, and came up with the following:

  1. To set the initial orientations that are supported when the app is first launched, use the "Supported Device Orientations" setting for your target. enter image description here Also back that up with the appropriate shouldAutorotateToInterfaceOrientation code, as you've already done.

  2. For subsequent screens, simply use the shouldAutorotateToInterfaceOrientation code to determine which orientations you want to support. Even if you've specified only landscape modes for the Supported Device Orientation, shouldAutorotateToInterfaceOrientation wins. :)

I think this approach is a little cleaner than using an extra dummy VC.

Sean McMains
  • 57,907
  • 13
  • 47
  • 54
  • This doesn't work for me, it disables those orientations for every view in my app. My app works in all orientations except for one or two rarely used views where the content only fits one way. – Abhi Beckert Oct 28 '13 at 22:03
1

I achieved a workaround for the Problem and it solved ,

I created a dummy view controller and added as the root view controller of the Window.

Added the below method in the implementation

    -(void)viewDidAppear:(BOOL)animated
    {
        WelcomeScreen *welcomeScreen = [[[WelcomeScreen alloc] initWithNibName:@"WelcomeScreen" bundle:nil] autorelease];
        [self presentModalViewController:welcomeScreen animated:NO];
    }

Now it worked as expected.

RVN
  • 4,157
  • 5
  • 32
  • 35
0

Here is a SO link that will hopefully answer your question on how to launch your app in landscape mode.

Community
  • 1
  • 1
bbarnhart
  • 6,620
  • 1
  • 40
  • 60
  • The link helps for the App with only landscape , but my app can work on all the modes , except the first screen which work only in Landscape. (anyway thanks for the answer). – RVN Feb 15 '12 at 14:39
  • If you set your app up as UIInterfaceOrientationLandscapeLeft and UIInterfaceOrientationLandscapeRight, are you saying that after the user moves past the initial landscape only view, if you configure your subsequent view controllers to support any orientation that the app will not work in portait mode? – bbarnhart Feb 15 '12 at 14:43