本文介绍了UITabBar不会隐藏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在UITabBarController中有一个UINavigationController,但似乎无法隐藏被推送的viewController的tabBar.
I have a UINavigationController in a UITabBarController, and I can't seem to get a pushed viewController's tabBar to hide.
我正在使用以下代码将其隐藏:
I am using the following code to hide it:
在它被推入之前:
tpsv.hidesBottomBarWhenPushed = YES;
tpsv.tabBarController.hidesBottomBarWhenPushed = YES;
viewWillAppear:
viewWillAppear:
self.tabBarController.tabBar.hidden = YES;
AppDelegate * del =(AppDelegate *)[[UIApplication sharedApplication]委托];
[[[[del tabController] tabBar] setHidden:YES];
但以上方法均无效.
如果您能告诉我如何解决此问题,那就太好了.
If you could tell me how to fix this, that would be great.
推荐答案
- (void) hideTabBar:(UITabBarController *) tabbarcontroller {
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.5];
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.5];
for(UIView *view in tabbarcontroller.view.subviews)
{
NSLog(@"%@", view);
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];
}
这篇关于UITabBar不会隐藏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!