title: ios swift - Presenting tab bar controller programatically
body: <p>I'm having a hard time presenting a tab bar controller that is not the root view controller.</p>
  
  <p>I have the current setup:
  <a href="https://i.stack.imgur.com/UrVBm.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/UrVBm.png" alt="enter image description here"></a></p>
  
  <p>I want to press a button in my main view controller and be able to present the tab bar controller with the option to go back to the main view controller.</p>
  
  <p>I tried creating a class of type UITabBarViewController, associating it to my Tab Bar Controller and just presenting it but it does not work.</p>
  
  <p>I would like to present the tab bar controller with the favorites tab selected.</p>
  
  <p>What I tried:</p>
  
  <pre><code>let vc = TabBar()
  
          self.presentViewController(vc, animated: true, completion: nil)
  </code></pre>