登录后引用情节提要时不显示快速导航栏

问题描述 投票:0回答:1

当我为应用程序启动构建时,登录和注册工作正常,但是当它转移到HomeVC故事板时,它似乎是空的。为了确保它被正确引用,我在上面贴上了标签,并且在构建过程中出现的标签实际上是导航栏。请帮助:)

如何在登录和注册中引用HomeVC故事板

登录名:

 else {
      let homeViewController = self.storyboard?.instantiateViewController(identifier: Constants.Storyboard.homeViewController) as? HomeViewController
       self.view.window?.rootViewController = homeViewController
       self.view.window?.makeKeyAndVisible()

注册:

func transitionToHome(){
     let homeViewController = storyboard?.instantiateViewController(identifier: Constants.Storyboard.homeViewController) as? HomeViewController
     view.window?.rootViewController = homeViewController
     view.window?.makeKeyAndVisible()

这里是登录情节提要Here is the login storyboard

导航条在情节提要中很明显The navigation bar is clearly apparent in the storyboards

ios swift xcode uistoryboard
1个回答
0
投票

您可以尝试使用segue

// This is used to perform the segue with the approporiate identifier
    self.performSegue(withIdentifier: "Your unique identifer of the seugue", sender: self)

// Prepare for segue is used if you want to modify some properities in the desintation viewcontroller
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
    if segue.identifier == "Your identifier of the segue" {
        // This is used to fetch the destination and cast it to pass over the values
        if let dc = segue.destination as? YourClassOfTheDestination {
            // Here can you type into dc and pass over the values

            //Example
            dc.curentFruit = "Pear"
        }
    }
}

这里是有关如何在情节提要中指定segue的自定义标识符的图像。 Here is the image

如果您不希望导航栏在某些屏幕上可见,您可以简单地使用:

override func viewWillAppear(_ animated: Bool) {
    super.viewWillAppear(animated)

    self.navigationController?.navigationBar.isHidden = true
}

override func viewWillDisappear(_ animated: Bool) {
    super.viewWillAppear(animated)

    self.navigationController?.navigationBar.isHidden = false
}

请记住在视图消失时使其再次可见。

很好的问题,希望答案会有所帮助!

© www.soinside.com 2019 - 2024. All rights reserved.