title: UIAlertController Not Behaving as expected
body: <p>I'm trying to switch from ViewController A to ViewController B and show a message with a <code>UIAlertController</code> in ViewController B.</p>
  <p>In my ViewController B I normally show my message like this in <code>viewDidLoad()</code>:</p>
  <pre><code>let alertMessage = String(format: &quot;This is an alert!!&quot;)
  let alertController = UIAlertController(title: &quot;Error!!&quot;, message: &quot;This is an alert!!&quot;, preferredStyle: .alert)
  alertController.addAction(UIAlertAction(title: &quot;Dismiss&quot;, style: .default))
  self.present(alertController, animated: true, completion: nil)
  </code></pre>
  <p>I switch from A to B like this:</p>
  <pre><code>let storyBoard:UIStoryboard = UIStoryboard(name:&quot;Main&quot;,bundle:nil)
  let nextViewController = storyBoard.instantiateViewController(withIdentifier: &quot;ViewControllerB&quot;) as! ViewControllerTypeB
  self.present(nextViewController, animated:false, completion:nil)
  </code></pre>
  <p>When I keep the code in ViewController B's <code>viewDidLoad()</code> as I have it above my alert does not appear and View Controller B is successfully switched to. One other thing I tried was changing the code in ViewController B's <code>viewDidLoad()</code> to:</p>
  <pre><code>let alertMessage = String(format: &quot;This is an alert!!&quot;)
  let alertController = UIAlertController(title: &quot;Error!!&quot;, message: &quot;This is an alert!!&quot;, preferredStyle: .alert)
  alertController.addAction(UIAlertAction(title: &quot;Dismiss&quot;, style: .default))                        
  UIApplication.shared.keyWindow?.rootViewController!.present(alertController, animated: true,
                                  completion: nil)
  </code></pre>
  <p>And now in this case when the code to go from A to B is called I see the alert shown on top of View Controller A, and View Controller B is never switched to.</p>
  <p>What is the correct way to accomplish this?</p>