How to implement UIViewController rotation in response to orientation changes?

Posted by Greg Maletic on Stack Overflow See other posts from Stack Overflow or by Greg Maletic
Published on 2010-05-14T23:37:29Z Indexed on 2010/05/14 23:44 UTC
Read the original article Hit count: 490

My app has about 10 different UIViewControllers, just one of which I want to switch to landscape mode if the device is rotated. (All the rest, I want to keep in portrait.)

In order to implement rotation on that one view, I needed to implement its controller's 'shouldAutorotate' method and return YES. Since this view is accessed via a navigation controller, I also needed to create a subclass of UINavigationController that implements 'shouldAutorotate' and return YES.

This solution works, but too well. I find that all of the UIViewControllers I push onto my subclass of UINavigationController respond to rotation, even if I implement 'shouldAutorotate' and return NO. (Remember: I only want one particular UIViewController to respond to rotation, not every one in the navigation controller's stack.)

So, my question is: how do I best do this? All the solutions I can come up with seem 1) cumbersome, and 2) worse, don't seem to work.

Thanks very much.

© Stack Overflow or respective owner

Related posts about iphone

Related posts about uiviewcontroller