2

这是我的一段代码,但是这样,当我推送第三级视图控制器时,标签栏不会显示。

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

2 回答 2

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];
} 
于 2012-06-11T07:56:25.907 回答
1

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

这种实现的一个例子是:

在 SecondLevelViewController.m 中

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

在 ThirdLevelViewController.m

-(void)viewWillAppear:(BOOL)animated
{
   [_bottomBar setHidden:NO];
}
于 2012-06-11T07:29:09.963 回答