-1

i have some navigations controller

Navigation Controller 1
Navigation Controller 2

when the user log off (red box), should be back to screen log in (yellow box) two navigation controllers are involved, the first one that is in the red box must die completely, just like that tab bar that is included.

this is the code of the close session button.

@IBAction func CerrarSesion(_ sender: Any)
{
    do
    {

        try Auth.auth().signOut()
        let vc = self.storyboard?.instantiateViewController(withIdentifier: "InicioSesionLogin")
        //self.dismiss(animated: true, completion: nil)
        self.present(vc!, animated: true, completion: self.borrarUserDefaults)


    }
    catch let error as NSError
    {
        print (error.localizedDescription)
    }
}

this code returns me to the view of logging in without a issue, but the views that are ahead are still working, I know because there is a view that uses location functions of beacons, and leave a function that prints ("ranging"). In summary: I want to return to the view to log in (red box) and kill all the views that I have in front of me.

the only thing I could do, is to kill the first navigation controller (yellow box) but it returns me to a back view, where you see the gray box.

Andres Gomez
  • 408
  • 3
  • 10

1 Answers1

0

if the navigation controller is the rootVc , you can reset it's viewcontrollers property

self.navigationController.viewControllers = [VC]

or reset the rootVC

UIApplication.shared.keyWindow?.rootViewController = // VC
Sh_Khan
  • 86,695
  • 6
  • 38
  • 57