title: Error when presenting AlertView on dismissing MFMessageController
body: <p>I am struggling with view hierarchy but I cannot figure out what is going wrong here. I try to send a message (<code>MFMessageComposeViewController</code>). I would like to show an <code>alertView</code> depending on the success (or not) with the help of delegate methods. The alertView is displayed when the message is cancelled but I get this error when the message is sent: </p>
  
  <pre><code>Attempting to load the view of a view controller while it is deallocating is not allowed and may result in undefined behavior (&lt;UIAlertController: 0x153b3c00&gt;)
  </code></pre>
  
  <p>It looks like as if the completion block was called before the <code>MFMessageComposeView</code> was completey dismissed (or deallocated) when the message is sent (as if there was still something running behind the scenes), but not when it is cancelled.
  If it can help:</p>
  
  <pre><code>- (void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult)result {
  
      int tag;
  
      switch (result) {
          case MessageComposeResultCancelled:
          {
              tag = 1;
              NSLog(@"Cancelled");
              break;
          }
          case MessageComposeResultFailed:
          {
              tag = 2;
              NSLog(@"Failed");
              break;
          }
  
          case MessageComposeResultSent:
          {
              tag = 3;
              NSLog(@"Sent");
              break;
          }
          default:
              break;
      }
      [controller dismissViewControllerAnimated:YES completion:^{
          [self alertSMSMessageWithTag:tag];
      }];
  }
  
  - (void)alertSMSMessageWithTag:(int)tag {
  
      UIAlertController *alertController;
  
      if (tag == 1) { // cancelled
          alertController = [UIAlertController alertControllerWithTitle:@"Message cancelled" message:nil preferredStyle:UIAlertControllerStyleAlert];
          UIAlertAction *ok = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:nil];
          [alertController addAction:ok];
      }
      if (tag == 2) { // Failed
          UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"Message failed" message:nil preferredStyle:UIAlertControllerStyleAlert];
          UIAlertAction *ok = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:nil];
          [alertController addAction:ok];
      }
      if (tag == 3) { // sent
          UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"Message sent" message:nil preferredStyle:UIAlertControllerStyleAlert];
          UIAlertAction *ok = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:nil];
          [alertController addAction:ok];
      }
      [self presentViewController:alertController animated:YES completion:nil];
  }
  </code></pre>
  
  <p>If anyone could help me...</p>