title: UIAlertController won't display - In Swift
body: <p>I have created a <code>ContactUsViewController</code>. </p>
  
  <p>In this controller the user will select a option from a <code>pickerView</code> and then type a message in a <code>textView</code> and press the Send Email button. </p>
  
  <p>When they press the button, it creates a <code>MFMailComposeViewController</code> so they can send the email. Now, when the email is either Sent, Saved, Cancelled or Failed, the <code>MFMailComposeViewController</code> closes as they are back in my app. I want an alert to then appear to give them an update, on what ever just happened. I have originally set this up using a UIAlertView, and have placed this code in the <code>fun mailComposeController</code> function, see below:</p>
  
  <pre><code>func mailComposeController(controller: MFMailComposeViewController, didFinishWithResult result: MFMailComposeResult, error: NSError?) {
  
      switch result.rawValue {
  
      case MFMailComposeResultCancelled.rawValue:
          NSLog("Email cancelled")
      case MFMailComposeResultSaved.rawValue:
          NSLog("Email saved")
          let sendMailErrorAlert = UIAlertView(title: "Email saved", message: "Your email has been saved in Mail.", delegate: self, cancelButtonTitle: "OK")
          sendMailErrorAlert.show()
      case MFMailComposeResultSent.rawValue:
          NSLog("Email sent")
  
          let alertController = UIAlertController(title: "test", message: "test", preferredStyle: .Alert)
          let okButton = UIAlertAction(title: "Okay", style: .Default, handler: nil)
          alertController.addAction(okButton)
          presentViewController(alertController, animated: true, completion: nil)
  
      case MFMailComposeResultFailed.rawValue:
          NSLog("Email failed: %@", [error!.localizedDescription])
          let sendMailErrorAlert = UIAlertView(title: "Oops!", message: "Looks like something went wrong, and the email couldn't send. Please try again later.", delegate: self, cancelButtonTitle: "OK")
          sendMailErrorAlert.show()
      default:
          break
  
      }
  </code></pre>
  
  <p>As you can see, I have used the <code>UIAlertView</code> for Email Saved and Email failed. <strong>This works absolutely fine, and shows my alert as expected.</strong></p>
  
  <p>I recently read that <code>UIAlertView</code> is depreciated since iOS 8, and that we should now use <code>UIAlertController</code>. Therefore I tried creating the same thing using the <code>UIAlertController</code>, which you can see for the Email Sent section. However, this doesn't seem to work, it just doesn't show any alert. It does print this error into the logs:</p>
  
  <pre><code>Warning: Attempt to present &lt;UIAlertController: 0x126c50d30&gt; on &lt;XXXX.ContactUsViewController: 0x1269cda70&gt; whose view is not in the window hierarchy! 
  </code></pre>
  
  <p>But I'm not really sure what this is saying, or more importantly, how to fix it. </p>
  
  <p><strong>My questions are:</strong></p>
  
  <ol>
  <li>Am I right in saying I cannot use <code>UIAlertView</code>?</li>
  <li>How can I fix this and make the <code>UIAlerController</code> appear after I have returned from the Mail app?</li>
  </ol>
  
  <p>Thanks in advance. </p>