iOS - 仅在一个视图上隐藏导航栏? [英] iOS - Hide navigation bar only on one view?

查看:212
本文介绍了iOS - 仅在一个视图上隐藏导航栏?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个登录视图控制器,在成功登录后,将我的用户推送到另一个视图控制器(ViewControllerB)。话虽这么说,ViewControllerB嵌入在UINavigationController中,我已经用菜单按钮格式化了。

I have a login view controller that, upon successful login, pushes my user to another view controller (ViewControllerB). That being said, ViewControllerB is embedded in a UINavigationController that I've already formatted with a menu button.

因为我正在使用来自登录视图控制器的push segue,所以这个segue会导致我的UINavigationBar被一个空白的导航栏和一个后退按钮覆盖(不酷) 。也就是说,我尝试使用以下代码从登录视图控制器隐藏导航控制器:

Because I'm using a push segue from the login view controller, this segue causes my UINavigationBar to be covered with a blank nav bar and a back button (not cool). That said, I tried to hide the navigation controller from login view controller with the following code:

loginviewcontroller.m

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

当我这样做时,带有后退按钮的不需要的导航栏覆盖了我的其他导航栏被删除!大。然而,当我导航到其他屏幕时,我的导航栏仍然隐藏(我想让它在我的用户通过ViewControllerB后出现)。

When I do this, the unwanted navigation bar with the back button covering my other nav bar is removed! Great. However when I then navigate to other screens, my nav bar remains hidden (and I want it to appear once my user makes it past ViewControllerB).

我尝试在成功登录时使用模态segue,但当然,这使我无法在登录时使用segues导航到其他屏幕。

I tried using a modal segue upon successful login, but of course, that keeps me from being able to navigate to other screens with segues upon login.

我知道怎么做这个吗?

推荐答案

添加:

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

这篇关于iOS - 仅在一个视图上隐藏导航栏?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆