R – Hide an UITabBar when Orientation change

cocoa-touchiphoneobjective-cuitabbarcontroller

I have a quite simple question but the answer is not so easy.

I want to hide a UITabBar when my orientation change.

I looked 2 ways :

Frame way

myAppDelegate.tabBarController.tabBar.frame = CGRectMake(<<bottomOfScreen>>);

Works fine but I have a blank area, so tried to play with tabBarController.view.frame et myViewController.view.frame but I didn't get any good result.

Navigation Controller Way

myOtherVC.hideTabBarWhenPushed = YES;
[self.navigationController pushViewController:myOtherVC animated:NO];

Works but isn't a good solution for my app

Update:

[appDelegate.tabBarController.view removeFromSuperview];
[self.view removeFromSuperview]; [appDelegate.window addSubview:self.view];
self.view.frame = CGRectMake(0,0,480,320);

Works fine but doesn't autorotate anymore (and of course, I didn't change the shouldAutorotate and it always returns YES)


How can I hidde my tabBar and make the current view taking its space ?


Thanks

Best Solution

You can use the current solution combined with:

[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didRotate:) name:@"UIDeviceOrientationDidChangeNotification" object:nil];

to detect rotation. (I think that you combine this with view.transform = CGAffineTransformMakeRotation to make it rotate...?)

Related Question