4

我有像 vc1 -> vc2 -> vc1 这样的视图控制器转换。我需要将 UINavigationBar 隐藏在 vc1 中,并显示在 vc2 中。

我执行以下操作:

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];

    self.navigationController.navigationBarHidden = YES;
}

- (void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:animated];

    self.navigationController.navigationBarHidden = NO;
}

在 iOS6 中,它运行良好。但是在iOS7中,当我从vc1回到vc2时,导航栏没有隐藏,而是在状态栏后面向上移动,过渡动画完成后导航栏被隐藏了。

我怎样才能真正隐藏导航栏?

4

2 回答 2

4

试试这样:

-(void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    [self.navigationController setNavigationBarHidden:YES];  
}

-(void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:animated];

    [self.navigationController setNavigationBarHidden:NO]; 
}

或尝试这样:

- (void)viewWillAppear:(BOOL)animated
{
    [self.navigationController setNavigationBarHidden:YES animated:animated];
    [super viewWillAppear:animated];
}

- (void)viewWillDisappear:(BOOL)animated
{
    [self.navigationController setNavigationBarHidden:NO animated:animated];
    [super viewWillDisappear:animated];
}
于 2013-10-31T04:06:45.407 回答
0

在 VC2 控制器中将其放入 - viewDidLoad

[self.navigationController setNavigationBarHidden:NO];

在 VC1 控制器中将其放入 -ViewDidLoad

[self.navigationController setNavigationBarHidden:YES];

然后VC1也添加这个

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    [self.navigationController setNavigationBarHidden:YES];
}

我希望它对你有帮助...

于 2013-10-31T04:15:04.220 回答