iOS 6 auto rotate confusion

19,396

Solution 1

In your Navigation Controller subclass, forward the decision to the top view controller in the stack:

-(NSUInteger) supportedInterfaceOrientations {
   return [self.topViewController supportedInterfaceOrientations];
}

Creating a separate storyboard file for this is the worst path to follow, it'll be a maintenance nightmare to keep them in sync with your app updates.

Solution 2

You should watch the WWDC'2012 videos especially the ones in the "Essentials" section talking about rotations.

The one called "T Evolution of View Controllers in iOS" explains the subject about rotations (and how to make them compatible with various iOS version) in great details, with explanations and code samples, and I couldn't explain it better than Apple ;)

Share:
19,396
Jake Dahl
Author by

Jake Dahl

Cross-platform developer.

Updated on June 04, 2022

Comments

  • Jake Dahl
    Jake Dahl almost 2 years

    I have my entire interface in one Storyboard. How can I make most of the ViewControllers only support a portrait orientation while only a couple supporting all orientations. I can't understand apples new auto rotate system. Also, how can I make this backwards compatable to iOS 5?

  • Jake Dahl
    Jake Dahl over 11 years
    I watched the video 2 times. From my interpretations of it i conclude that i have to subclass a navController to achieve what i want. I tried that and it worked...for the first viewController in the stack. I don't know how to make it work for vc's further down the stack. BASICALLY all of my vc's either will, or will not rotate.
  • AliSoftware
    AliSoftware over 11 years
    Then why don't you implement/override the supportedInterfaceOrientations method in each of your ViewController, depending on if it has to rotate or not?!
  • Jake Dahl
    Jake Dahl over 11 years
    I did, and I checked using NSLog and it gets called. But whatever behavior I set in the first ViewController (AutoRotate=YES, supportIngerfaceOrientation=Portrait) is what happens in all other view controllers that get pushed on the navigation stack. Also I checked on the other vc's with NSLog to see if they check for shouldAutorotate and that never gets called
  • Jake Dahl
    Jake Dahl over 11 years
    Ok, i improvised early in this project to maintain iOS 5 compatibility, but still be able to use the AWESOME new Auto Layout system. My initial Storyboard is just 1 View Controller embedded in a navController. In the implementation of that viewController i check the current OS version, then present a storyboard. I have 2 identical ones, except one has auto-layout enabled. ALL O HAD TO DO was set that initial navController's class to my "RootVC" that has the 6 lines or so of the new auto-rotate API. I do have to say, this approach is far more confusing and I think poorly explained by Apple.
  • Rafael Nobre
    Rafael Nobre over 11 years
    In your root subclass, you should call down to the topViewController's method, instead of returning actual values.
  • Jake Dahl
    Jake Dahl over 11 years
    That makes the most sense and I will be implementing that. I don't know how else to use auto-layout and maintain iOS 5 compatability