顶部导航栏不出现

Top navigation bar doesn't appear

我有一个顶部导航栏,上面有一个注销按钮,returns 用户可以通过该按钮返回登录屏幕并从他们的钥匙串中擦除他们的访问令牌。

我正在努力添加一个滑出式菜单栏,但是,我的顶部导航栏没有出现,而且我似乎无法让它出现。

我使用以下代码摘录在成功登录时展示此视图:

DispatchQueue.main.async {
    let homePage = 
        self.storyboard?.instantiateViewController(withIdentifier:
        "HomePageViewController") as! HomePageViewController
    self.present(homePage, animated: true)
}

您必须出示 HomePageViewController 中的 UINavigationController,而不是出示 HomePageViewController

  • HomePageViewControllerUINavigationController 设置故事板 ID。例如,您将 UINavigationController 的故事板 ID 设置为 HomePageNavigation
  • 用下面的代码替换您的代码。

    DispatchQueue.main.async {
        let homePage = 
            self.storyboard?.instantiateViewController(withIdentifier:
    "HomePageNavigation") as! UINavigationController
        self.present(homePage, animated: true)
    }
    
故事板上

Select UINavigationControllerHomePageController

更改 UINavigationController 的故事板 ID。