如何隐藏uitabbarcontroller [英] How to hide uitabbarcontroller
问题描述
我遇到了 UITabBarController
的问题。在我的应用程序中,我想隐藏它但不使用 hidesBottomBarWhenPushed
因为我想要隐藏它而不是在我推动它时。例如,我想在我的应用程序中按隐藏按钮时隐藏它。
I have a problem with UITabBarController
. In my application, I want to hide it but without using hidesBottomBarWhenPushed
because I want to hide it not when I pushed it. For Example, I want to hide it when I press a Hide button in my application.
我在谷歌阅读了很多文章,但我无法知道如何做到这一点。
I read many articles in google but I cant find out how I can do this.
推荐答案
我从我的工作代码中粘贴这个...你可以调用这些方法来隐藏和显示tabbarcontroller ......只需将tabbarcontroller实例传递给这些函数..
I am pasting this from my working code... you can call these methods to hide and show the tabbarcontroller.... just pass tabbarcontroller instance to these functions..
// Method call
[self hideTabBar:self.tabBarController];
// Method implementations
- (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];
}
这篇关于如何隐藏uitabbarcontroller的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!