简体   繁体   English

导航栏状态,显示和隐藏底部导航栏

[英]navigation bar states, showing and hiding the bottom nav bar

Keep in mind with the following question, I am still an iOS noob. 请记住以下问题,我仍然是iOS新手。

So I understand how to hide/show/recolor the navigation bar and whatnot. 因此,我了解了如何隐藏/显示/重新着色导航栏等。 My next challenge is that some screens need the nav bar and others do not. 我的下一个挑战是,某些屏幕需要导航栏,而其他屏幕则不需要。

When my app starts off, I have the nav bar as hidden and then the user can click register or log in (both of which screens have a nav bar). 当我的应用程序启动时,我将导航栏隐藏起来,然后用户可以单击注册或登录(两个屏幕都具有导航栏)。

So those screens have the code to show the nav bar all while the first (welcome screen) has the code to hide the nav bar. 因此,这些屏幕均具有显示导航栏的代码,而第一个屏幕(欢迎屏幕)具有隐藏导航栏的代码。

Here is the question: Why is it that when I first start my app, the nav bar is not there, but when I go to register/login and then hit the back button to return to the welcome page (initial page) then the nav bar is still there, even though my code to hide it is in the viewDidLoad method? 这是一个问题:为什么当我第一次启动我的应用程序时,导航栏不存在,但是当我去注册/登录然后单击后退按钮以返回到欢迎页面(初始页面)时,为什么导航即使我隐藏它的代码在viewDidLoad方法中,酒吧仍然在那里? How can I fix this? 我怎样才能解决这个问题?

You can try moving the logic of hidding the Nav bar to the ViewWillAppear method, you just need to override it in your View Controller class. 您可以尝试将隐藏导航栏的逻辑移到ViewWillAppear方法,您只需要在View Controller类中重写它即可。

Alternatively I would suggest to use a separate view controller to handle your login/registration screens and only use nav bars where you need them. 另外,我建议您使用单独的视图控制器来处理您的登录/注册屏幕,并仅在需要时使用导航栏。 You would have to create a view controller in your story board with your regular screens and embed the screens that need the tab bar in a navigation controller, You can then segue from your regular view controller into the navigation controller that includes your tabs. 您将必须在故事板中使用常规屏幕创建一个视图控制器,然后将需要选项卡栏的屏幕嵌入到导航控制器中,然后才能从常规视图控制器中选择包含选项卡的导航控制器。

Hope this helps 希望这可以帮助

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM