我的应用程序中有 5 个选项卡,第一个选项卡是欢迎选项卡,当用户单击第一个选项卡时它会显示欢迎屏幕,但仅在第一个选项卡上我想隐藏选项卡栏 我想隐藏第一个选项卡上的选项卡栏,因为它是一个受欢迎的 View 。我进行了搜索,但无法隐藏它,我在欢迎 Controller View didload 中执行了此操作。
[self.tabBarController.tabBar setHidden:YES];
它隐藏但留空空间。
使用 xcode 4.3.2、storyboard、ios 5
最佳答案
如果隐藏 tabBar 那么如何导航到第二个和第三个选项卡。 我建议添加welcomeView并在welcomeView之后添加tabBar。
或者您可以使用此代码
[self hideTabBar:self.tabBarController];
- (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];
}
[self showTabBar:self.tabBarController];
- (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];
}
关于Iphone 在第一个选项卡上隐藏 uitabbar,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12423713/