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:
self.view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
Add this delegate method in the controller in which you want to add a view to be rotated:
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
{
//NSLog(@"didRotateFromInterfaceOrientation");
if((fromInterfaceOrientation == UIInterfaceOrientationPortrait) ||
(fromInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown))
{
YourAppDelegate *mainDelegate = (YourAppDelegate *)[[UIApplication sharedApplication] delegate];
[mainDelegate.tabBarController.view addSubview: viewToBeRotated];
[viewToBeRotated setHidden:NO];
return;
}
if(fromInterfaceOrientation == UIInterfaceOrientationLandscapeLeft || fromInterfaceOrientation == UIInterfaceOrientationLandscapeRight)
{
[viewToBeRotated removeFromSuperview];
[self.view setHidden:NO];
}
}
You may also want to add the following method:
- (void)willAnimateFirstHalfOfRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
duration:(NSTimeInterval)duration {
if (toInterfaceOrientation == UIInterfaceOrientationPortrait)
{
//self.view = self.portrait;
YourAppDelegate *mainDelegate = (YourAppDelegate *)[[UIApplication sharedApplication] delegate];
[viewToBeRotated removeFromSuperview];
mainDelegate.tabBarController.view.transform = CGAffineTransformIdentity;
mainDelegate.tabBarController.view.transform = CGAffineTransformMakeRotation(degreesToRadian(0));
mainDelegate.tabBarController.view.bounds = CGRectMake(0.0, 0.0, 300.0, 480.0);
}
else if (toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft)
{
YourAppDelegate *mainDelegate = (YourAppDelegate *)[[UIApplication sharedApplication] delegate];
[mainDelegate.tabBarController.view addSubview: viewToBeRotated];
mainDelegate.tabBarController.view.transform = CGAffineTransformIdentity;
mainDelegate.tabBarController.view.transform = CGAffineTransformMakeRotation(degreesToRadian(-90));
mainDelegate.tabBarController.view.bounds = CGRectMake(0.0, 0.0, 460.0, 320.0);
}
else if (toInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown)
{
//self.view = self.portrait;
YourAppDelegate *mainDelegate = (YourAppDelegate *)[[UIApplication sharedApplication] delegate];
[viewToBeRotated removeFromSuperview];
mainDelegate.tabBarController.view.transform = CGAffineTransformIdentity;
mainDelegate.tabBarController.view.transform = CGAffineTransformMakeRotation(degreesToRadian(180));
mainDelegate.tabBarController.view.bounds = CGRectMake(0.0, 0.0, 300.0, 480.0);
}
else if (toInterfaceOrientation == UIInterfaceOrientationLandscapeRight)
{
YourAppDelegate *mainDelegate = (YourAppDelegate *)[[UIApplication sharedApplication] delegate];
[mainDelegate.tabBarController.view addSubview: viewToBeRotated];
mainDelegate.tabBarController.view.transform = CGAffineTransformIdentity;
mainDelegate.tabBarController.view.transform = CGAffineTransformMakeRotation(degreesToRadian(90));
mainDelegate.tabBarController.view.bounds = CGRectMake(0.0, 0.0, 460.0, 320.0);
}
}
You may also want to take a look at
http://stackoverflow.com/questions/730799/rotating-the-iphone-and-instantiating-a-new-uiviewcontroller
http://stackoverflow.com/questions/756536/tabbarcontroller-and-navigationcontrollers-in-landscape-mode-episode-ii