这是我的一段代码,但是这样,当我按下第三级视图控制器时,tabbar不会显示。
//at first level
SecondLevelViewController *_2vc = [[SecondLevelViewController alloc]initWithNibName:@"SecondLevelViewController" bundle:nil];
_2vc.hidesBottomBarWhenPushed = YES;
[self.navigationController pushViewController:_2vc animated:YES];
//at second level
ThirdLevelViewController *_3vc = [[ThirdLevelViewController alloc]initWithNibName:@"ThirdLevelViewController" bundle:nil];
_3vc.hidesBottomBarWhenPushed = NO;
[self.navigationController pushViewController:_3vc animated:YES];
答案 0 :(得分:3)
// Load the view
AddViewController *aController = [[AddViewController alloc] init];
// Set the view title
aController.title = @"Add View";
// hide tabbar
aController.hidesBottomBarWhenPushed = YES;
// add it to stack.
[[self navigationController] pushViewController:aController animated:YES];
-(void)viewWillAppear: (BOOL)animated
{
[super viewWillAppear:animated];
[self.tabBarController.tabBar setHidden:YES];
}
-(void)viewWillDisappear: (BOOL)animated
{
[super viewWillDisappear:animated];
[self.tabBarController.tabBar setHidden:NO];
}
答案 1 :(得分:1)
而不是在初始化视图控制器时设置hidesBottomBarWhenPushed的值,而是应该在视图控制器中动画的 - (void)viewWillAppear:(BOOL)中处理隐藏机制。
这种实现的一个例子是:
在SecondLevelViewController.m
中-(void)viewWillAppear:(BOOL)animated
{
[_bottomBar setHidden:YES];
}
在ThirdLevelViewController.m中
-(void)viewWillAppear:(BOOL)animated
{
[_bottomBar setHidden:NO];
}