Search code examples
swiftuiviewcontrolleruinavigationcontrollersegue

A navigationcontroller appears out of no where when I create a segue to logout - Swift


So I placed a logout button, and created a segue to the first view controller where users can either log in or sign up. For some reason, when I created the segue, in the first view controller appeared a navigation controller, as if it were embedded, but it's not. If I delete the segue, the navigation disappears. I tried creating a new button, but the same problem appears. Here's a screenshot of how the navigation appears in my app. P.S I am using Swift

Image here. Notice the navigation controller.

I'd really appreciate it if someone could help me figure this out.


Solution

  • You need to understand, UINavigationController properly. No matter UINavigationController is initial or not, but from where you are creating segue, there must exist UINavigationController. So, you are getting a UINavigationBar and a back button.

    You can still disable that from UIStoryboard by selecting Top Bar to None.

    enter image description here

    Well, if you wish to do it from coding then do it via following way in your ViewController class:

    override func viewWillAppear(_ animated: Bool) {
        self.navigationController?.setNavigationBarHidden(true, animated: false)
    }
    

    Let me know, if you still face any issue.