title: How to PopUp or Modally Present View Controller from Tab Bar Controller?
body: <p>How can I create a popup that appears when a button on a Tab Bar is pressed? I would like something similar to this: <a href="https://www.youtube.com/watch?v=zDWSaItF2ko" rel="nofollow noreferrer">https://www.youtube.com/watch?v=zDWSaItF2ko</a>.</p>
  
  <p>I have tried many solutions but none have worked.</p>
  
  <p>For example, I have tried this with my main view controller:</p>
  
  <p>This still doesn't work though. How would I go about creating this. I know that I need to present the view controller modally and over current context, but how would I do that from a tab bar controller.</p>
  
  <pre><code>func tabBarController(_ tabBarController: UITabBarController, shouldSelect viewController: UIViewController) -&gt; Bool {
      if viewController is PopupViewController {
          if let popupView = tabBarController.storyboard?.instantiateInitialViewController() {
              popupView.modalPresentationStyle = .fullScreen
              tabBarController.present(popupView, animated: true, completion: nil)
  
              return false
          }
      }
      return true
  }
  </code></pre>
  
  <p>Here are some pictures that may help:</p>
  
  <p>Main Storyboard:</p>
  
  <p><img src="https://i.stack.imgur.com/iEecA.png" alt="Main Storyboard"></p>
  
  <p>Popup Storyboard:</p>
  
  <p><img src="https://i.stack.imgur.com/3wgeI.png" alt="Popup Storyboard"></p>
  
  <p>View Controller Code:</p>
  
  <p><img src="https://i.stack.imgur.com/TgA9V.png" alt="View Controller Code"></p>