My main view controller is a UITabBarController
, with 4 UINavigationControllers
as the tab bar items. Each navigation bar is a couple of different views that get pushed onto it's stack.
I have a single view that I want autorotated, but I can't get willAnimateFirstHalfOfRotationToInterfaceOrientation
to be called within that view controller.
I've tried subclassing my UITabBarController
and UINaviationControllers
and adding an override for shouldAutorotateToInterfaceOrientation
like so:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return YES;
}
Even after that I can't get the view to rotate. I figured maybe the top-most UIViewController
(tab and navigation included) has to be able to rotate. Or even every view up the chain. I've tried overriding shouldAutorotateToInterfaceOrientation
for every controller but still can't get the view to rotate.
Anyone accomplished this or have any suggestions?
Thanks in advance!
Besides subclassing your tabBarController as you did overriding houldAutorotateToInterfaceOrientation, you must do the following:
In the viewDidLoad method of the controller in which you want to add a view to be rotated:
Add this delegate method in the controller in which you want to add a view to be rotated:
}
You may also want to add the following method:
You may also want to take a look at
Rotating the iPhone, and instantiating a new UIViewController
TabBarController and navigationControllers in landscape mode
subclassing UITabBarController and overriding this method worked:
I think my real problem was XCode not compilingthe updated code. I did Build clean, touch and restarted XCode and the simulator and the changes finally took.
You can use a SubClassed
UITabBarController
(or use an addition) that asks the selected navigationController for thevisibleViewController
's response to rotation request: