title: MFmailComposer error
body: <p>I want to apologize in advance because I am fairly new to programming, so if I am not as specific as I can be I am sorry but I will try to explain my problem as best as I can anyways, I am creating an app that needs to have the ability to send emails and I have looked everywhere, tried every sample code I could find and nothing seems to work every time I use code I get the following error: </p>
  
  <blockquote>
    <p>2013-02-03 20:23:39.372 Tones[16409:c07] Warning: Attempt to present
     on </p>
  </blockquote>
  
  <p>whose view is not in the window hierarchy!</p>
  
  <p>This is the code I am currently using in the <strong>viewcontroller.h</strong> file:</p>
  
  <pre><code>UIViewController &lt;MFMailComposeViewControllerDelegate&gt;
  - (IBAction)Mail:(id)sender;
  </code></pre>
  
  <p>and this is in my <strong>viewcontroller.m</strong> file:</p>
  
  <pre><code>- (IBAction)Mail:(id)sender {
  if ([MFMailComposeViewController canSendMail]) {
      MFMailComposeViewController *mail = [[MFMailComposeViewController alloc] init];
  
      mail.mailComposeDelegate = self;
  
      [mail setSubject:@"Subject"];
  
      NSArray *recipient = [NSArray arrayWithObjects:@"mail@example.com", nil];
      [mail setToRecipients:recipient]; 
  
      NSString *body = @"body!";
      [mail setMessageBody:body isHTML:NO];
  
      [self presentModalViewController:mail animated:YES];
  }
  }
  - (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error
  {
  [self dismissModalViewControllerAnimated:YES];
  }
  </code></pre>
  
  <p>I also get a message that says both self <code>presentModalViewController</code> and self <code>dismissModalViewController</code> is deprecated in IOS 6 so does that mean I cant use it or am I doing something wrong?</p>
  
  <p>So any help on what I am doing wrong with the mail composer would be much appreciated and again im sorry if I was not specific enough thanks in advance </p>