这是我的一部分代码,但是通过这种方式,当我按下第三级视图控制器时,标签栏将不会显示。

//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];

最佳答案

代替在初始化视图控制器时设置hidesBottomBarWhenPushed的值,而应在视图控制器中设置动画的-(void)viewWillAppear:(BOOL)中处理隐藏机制。

此实现的示例为:

在SecondLevelViewController.m中

-(void)viewWillAppear:(BOOL)animated
{
   [_bottomBar setHidden:YES];
}

在ThirdLevelViewController.m中
-(void)viewWillAppear:(BOOL)animated
{
   [_bottomBar setHidden:NO];
}

关于ios - UINavigationController,如何在第二级viewController中隐藏选项卡,然后在第三级viewController中显示选项卡,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/10975215/

10-12 15:47