Question

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

Was it helpful?

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...?)

OTHER TIPS

Two ways I think you can easily do this would be:

  1. to reload the objects back into the tabBar controller - with the hidesBottomBarWhenPushed set to YES for the viewControllers you want to be hidden.
  2. The other option would be to just make your view the only view for the window when the phone is rotated and then put the tabBarController.view back in the window when the phone is rotated back

Hope this helps

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top