I've got a UITabBarController containing different UINavigationControllers. One of those UINavigationController's rootViewController displays a chart (using ShinobiCharts) between the UINavigationBar and the UITabBar in portrait mode. When turning to landscape, I'd like to hide both the UINavigationBar and the UITabBar and display my chart full screen. Not a problem for the navigation bar, I don't know how to that for the tab bar. I can hide it but resizing the chart after hiding does not make it as big as I want it to be.

This seems to be a pretty straight forward demand and I bet there's a fairly simple solution, isn't it?

有帮助吗?

解决方案

Have a look at How to hide uitabbarcontroller.

Essentially you change the size of the tab bar view so that the tab bar is outside of the window bounds.

其他提示

- (void)hideTabBar:(UITabBarController *) tabbarcontroller
{
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.3];

for(UIView *view in tabbarcontroller.view.subviews)
{
if([view isKindOfClass:[UITabBar class]])
{
  [view setFrame:CGRectMake(view.frame.origin.x, 480, view.frame.size.width,            
  view.frame.size.height)];
}
else
{
  [view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y,        
  view.frame.size.width, 480)];
}
}

[UIView commitAnimations];
}

- (void)showTabBar:(UITabBarController *) tabbarcontroller
{
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.3];

for(UIView *view in tabbarcontroller.view.subviews)
{
if([view isKindOfClass:[UITabBar class]])
{
  [view setFrame:CGRectMake(view.frame.origin.x, 431, view.frame.size.width,    
  view.frame.size.height)];

}
else
{
  [view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y,  
  view.frame.size.width, 431)];
 }
}

[UIView commitAnimations];
}

The thing here is, simply hiding the tabBar is not a solution, since the nested subviews will not be resized.

I use the above code when I want to hide the tabBar and resize it's subviews. You will have to do the hide/show the frames BEFORE you push your viewController (with the chart).

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top