Note that there are some explanatory texts on larger screens.

plurals
  1. POIOS 6 force device orientation to landscape
    primarykey
    data
    text
    <p>I gave an app with say 10 view controllers. I use navigation controller to load/unload them. </p> <p>All but one are in portrait mode. Suppose the 7th VC is in landscape. I need it to be presented in landscape when it gets loaded. </p> <p><strong>Please suggest a way to force the orientation go from portrait to landscape in IOS 6</strong> (and it will be good to work in IOS 5 as well).</p> <p>Here is how I was doing it <strong>BEFORE</strong> IOS 6:</p> <pre><code>- (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; UIViewController *c = [[[UIViewController alloc]init] autorelease]; [self presentModalViewController:c animated:NO]; [self dismissModalViewControllerAnimated:NO]; } - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation{ return (interfaceOrientation == UIInterfaceOrientationPortrait); } </code></pre> <p>Presenting and dismissing a modal VC was forcing the app to review its orientation, so <code>shouldAutorotateToInterfaceOrientation</code> was getting called.</p> <p><strong>What I have have tried in IOS 6:</strong></p> <pre><code>- (BOOL)shouldAutorotate{ return YES; } -(NSUInteger)supportedInterfaceOrientations{ return UIInterfaceOrientationMaskLandscape; } - (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation{ return UIInterfaceOrientationLandscapeLeft; } </code></pre> <p>On load, the controller keeps staying in portrait. After rotating the device, the orientation changes just ok. But I need to make the controller to rotate automatically to landscape on load, thus the user will have to rotate the device to see the data correctly.</p> <p>Another problem: after rotating the device back to portrait, the orientation goes to portrait, although I have specified in <code>supportedInterfaceOrientations</code> only <code>UIInterfaceOrientationMaskLandscape</code>. Why it happens?</p> <p>Also, <strong>NONE</strong> of above 3 methods are getting called.</p> <p><strong>Some (useful) data:</strong></p> <ol> <li>In my plist file I have specified 3 orientations - all but upside down.</li> <li>The project was started in Xcode 4.3 IOS 5. All classes including xibs were created before Xcode 4.5 IOS 6, now I use the last version.</li> <li>In plist file the status bar is set to visible.</li> <li>In xib file (the one I want to be in landscape) the status bar is "None", the orientation is set to landscape.</li> </ol> <p>Any help is appreciated. Thanks. </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload