Question: I have an issue with the `presentViewController`function.

I have a login menu (A) and a button who display a login form (B). On success login, I present a third view with `self.presentViewController` (C).

Login menu (A) -> Login form (B) -> Content (C)

It's work, I can present the third view (C) but the login menu (A) is always visible (I can see it in UI Debug mod).

So, how to close the A ViewController?

Answer: 
`presentViewController`, presents a view controller modally. In other words, over the current view controller’s content, and the current view controller will not get deallocated.

Use the following code for your sample:

```
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let vc = storyboard.instantiateViewController(withIdentifier: <Identifier as in Storyboard of C>)
(UIApplication.shared.delegate as! AppDelegate).window?.rootViewController = vc

```

If you would like to include a transition, you could replace the last line with something as the following:

```
UIView.transition(from: currentRootViewController!.view, to: vc.view, duration: 0.8, options: .transitionCrossDissolve, completion: { (_) in
      (UIApplication.shared.delegate as! AppDelegate).window?.rootViewController = vc
})

```
I think this tutorial has your answer <https://www.youtube.com/watch?v=WIaRs2d6Xm0>