【问题标题】:Swift 4: NavigationController Not Showing Bar on Subsequent PagesSwift 4:NavigationController 在后续页面上不显示栏
【发布时间】:2018-04-19 15:22:48
【问题描述】:

我将 LoginVC 嵌入到 NavigationController 中,并在登录时将用户推送到 SwitchboardVC。

如果用户已经登录,我会在 didFinishLaunchingWithOptions 的 AppDelegate 中使用此代码绕过登录屏幕:

if Auth.auth().currentUser != nil
{
    let mainStoryBoard: UIStoryboard = UIStoryboard(name:"Main", bundle:nil)
    let nextView: SwitchboardVC = mainStoryBoard.instantiateViewController(withIdentifier: "SwitchboardVC") as! SwitchboardVC
    self.window?.rootViewController = nextView
}

当我必须登录时,导航栏会显示在所有屏幕上,但如果我已经登录,导航栏会在所有其他屏幕上消失。

我还没有在 Google 上找到解决方案,但我假设我没有在搜索正确的术语。

非常感谢任何帮助

【问题讨论】:

    标签: ios swift uinavigationcontroller


    【解决方案1】:

    我相信这是因为您将根设置为 newView 而不是从 navigationController 推送 newView,这会将其添加到导航堆栈并将栏保持在顶部。 对于导航层次结构,这里有一些阅读: https://medium.com/@strawb3rryx7/swift-the-hierarchy-of-uinavigationcontroller-programmatically-91631990f495

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-09-25
      • 2018-05-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-07-02
      相关资源
      最近更新 更多