views:

382

answers:

2

I'm trying to implement auto-rotation in my application that is basically UINavigationController with lots of UIViewControllers that get pushed onto it.

I've copy-pasted this in my first UIViewController (that gets pushed into UINavigationController):

- (BOOL)shouldAutorotateToInterfaceOrientation:
(UIInterfaceOrientation)interfaceOrientation {
 return YES;
}

Everything worked fine... However, if I paste in that code into second UIViewController (that first one pushes on top after some button click) - autorotation won't work. shouldAutorotateToInterfaceOrientation gets called when UIViewController is first initialized, but after it is visible and I rotate device - nothing happens.

So result is: first view gets rotated well - portrait/landscape... but after I click button and get into second view I remain stuck into that portrait or landscape, whatever was active.

I tried subclassing UINavigationController and setting shouldAutorotateToInterfaceOrientation there, but that also doesn't work.

What am I doing wrong?

A: 

You need to implement this method in all views in the hierarchy

BobC
I said in question that I tried implementing it in all views (and that it only worked for first view).
kape123
+1  A: 

There's a bug in the API that doesn't cause it to work for the second view. I solved it originally using setOrientation, but that's a private API and thus not a reasonable solution. I haven't released any new versions of the application while I try to figure out alternatives (and I don't think having customers upgrade to OS 4.0 is a solution). I'm thinking I'll need to manually keep track of the orientation and rotate my views manually to counteract the effects of the wrong rotation.

Epsilon Prime
Please see my response here as additional information: http://stackoverflow.com/questions/3213885/ipad-orientation-change-issue/3239351#3239351
iWasRobbed