I\'m returning YES in my view controller\'s shouldAutorotateToInterfaceOrientation function, and I can see using breakpoints that YES
One thing to look for is I found if I had UIPopoverController called in [UINavigationController viewDidAppear], then willRotateToInterfaceOrientation and didRotateFromInterfaceOrientation are not called. It looks like UIPopoverController being modal blocks the rotation method calls.
Yes me too. Ok, it won't get called in a sub-viewcontroller - have to pass it down. Can deal with that. And the notification idea works well except that you only get "did..." not "will..." (afaik) and anyway it's a messy solution to a problem which shouldn't be there.
My mistake was to call [super loadView] in my loadView. Not supposed to do that. When I removed [super loadView] and alloc'd the view myself willRotateToInterfaceOrientation started working.
What's really weird is that the [super loadView] was in the sub-viewcontroller and the event wasn't even reaching the top one...
Apple documentation
At launch time, apps should always set up their interface in a portrait orientation. After the application:didFinishLaunchingWithOptions: method returns, the app uses the view controller rotation mechanism described above to rotate the views to the appropriate orientation prior to showing the window.
So if you are using a TabBarViewController be carefull to set up the selected view in the application:didFinishLaunchingWithOptions: method.
Is this views viewController a subview of some other root view controller thats not a navigation controller? if so then the call does not propagate to the subviews controller, so that might be why your view isnt rotating.
If you are not receiving callbacks on willAutoRotateToInterfaceOrientation in any view controller, add the view controller as your root view controller's child view controller.
For Eg; say self.viewController is your root view controller and childViewController is the view controller in which you want to get auto-rotation callbacks, add the following line of code;
[self.viewController addChildViewController:childViewController];
Actually, adding as the child view controller to any view controller which gets rotation call backs will work too.
Hope it helps.
I have a similar problem and saw Daniel's answer however I can't find any confirmation of this in the developer documentation. Not that I don't believe the answer but I don't really understand why the orientation call does not propagate.
Someone gave me a trick that works using something like this:
[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(detectOrientation) name:@"UIDeviceOrientationDidChangeNotification" object:nil];