iOS how to change rootViewController when dismissController
<p><a href="https://i.stack.imgur.com/IxbJi.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/IxbJi.png" alt="enter image description here"></a></p>

<p>my storyboard </p>

<p>If user doesn't login, the rootViewController is <code>Login</code></p>

<p>after user login done, rootViewController is MainTabBarController</p>

<p>I have done that </p>

<p>But, I have encounter question is <code>Logout</code></p>

<p>My <code>Logout</code> is dismissViewController</p>

<p>If my rootViewController is <code>Login</code>, it works</p>

<p>It will remove current ViewController, so <code>Login</code> appear</p>

<p>But when my rootViewController is <code>MainTabBarController</code>, dismiss is not work, I've try using <code>poptoRootViewController</code> in vain.</p>

<p>what should I do in <code>Logout</code> ?</p>

<p>I want to do like this</p>

<pre><code>dismissController(true,{
   rootViewController = `Login`
})
</code></pre>