Storyboard and Orientation

I have an app (itunes.apple.com/app/westmont/id364494194?mt=8) that needs to support landscape mode in just one view controller.

The entire app is built in portrait mode, however, the one VC that is a UIWebView that needs to support landscape since it points to archived sports games from the college. I’ve researched and tried various attempted solutions on Stack Overflow and others, but can’t seem to get it to work. Here’s what I have so far:

In the project file, the only Supported Interface Orientation is Portrait. One attempted solution was to add Landscape Left/Right and modify every VC with shouldAutorotateToInterfaceOrientation but that didn’t work past the first VC I tried it on.

The app’s AppDelegate class is

  • (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
    }
    I tried to just change this, but no dice there either.

I added that code to the VC that needed to be changed, but it didn’t work either. I came across something that talked about the parent VC needing to have this code but I’m not sure that’s what I have here. Here’s the order of what I have in storyboard:
Tab Controller -> Navigation Controller -> TableViewController -> UIWebView.

Your help is appreciated!

Are you running your app on iOS 6? If so, -shouldAutorotateToInterfaceOrientation: is now deprecated. You should use -supportedInterfaceOrientations instead.

There is a crucial difference between the “supported interface orientations” in Xcode’s target summary and the values you return from these methods:

The “supported interface orientations” field in Xcode only indicates the orientations in which the app is willing to launch initially, before your first view controller takes over.

Each view controller, however, is responsible for identifying the orientations at which that vc is willing to display.

No, I’m not running iOS 6.

I unselected the “Supported interface orientations” in the target summary and used this code in the first view controller:

  • (BOOL)shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation)interfaceOrientation {
    return (interfaceOrientation == UIInterfaceOrientationLandscapeRight || interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationPortrait);
    }

and it didn’t work. I did some searching and found that the tab bar controller needed to be subclassed and that piece of code entered there. When I did that, all the view controllers rotated equally. So when you said, "Each view controller is responsible for identifying the orientations at which that vc is willing to display, I tried to limit a view controller by doing “return (interfaceOrientation == UIInterfaceOrientationPortrait);” it wouldn’t work and only stuck to what the tab bar controller subclass was telling it to do. What was I doing wrong?

I did find this nugget of info somewhere: “By default, tab views only allow autorotation if all of the contained view controllers support autorotation.” I’m guessing that has something to do with it. Help is appreciated.

Alright - I decided to support iOS 6 after some issues with supporting iOS 5 and running iOS 6 on my phone. I used this Stack Overflow answer which is really great: stackoverflow.com/a/12505461/1050388 but I’m still seeing a weird quirk. I can’t reply on SO because I don’t have enough reputation. :slight_smile:

I blocked all but one VC from turning, but that VC is in the “More” tab. When I navigate to that tab in the “More” list, and turn the VC, it doesn’t rotate. When I click “Edit” and move it to the initial 4 tabs, it rotates just fine. How annoying. Anyone have an idea why this is happening?