Search code examples
swiftuinavigationbar

navigation bar is not hidden after pressing back button


When i perform segue self.performSegue(withIdentifier: "GoToClientScreen", sender: nil) then i click back button in navigation bar then in my home screen navigation bar is not hidden

home screen Code ->

   @IBAction func nextBtn(_ sender: UIButton) {
    self.performSegue(withIdentifier: "GoToClientScreen", sender: nil)
    }

Client Screen Code ->

 override func viewDidLoad() {
    super.viewDidLoad()
    self.navigationController?.setNavigationBarHidden(false, animated:  true)
 }

see in image ->

open app then press next All things is fine

and press Back Button here i want navigation bar here is also looks good

and navigation bar is not hidden here is an issue


Solution

  • On First Screen Hide the navigation bar.

    In the ViewWillAppear method, write the following code.

    self.navigationController?.setNavigationBarHidden(true, animated: false)
    

    This will resolve this issue.