开发者

Problem displaying MFMailComposeViewController modal view

I'm having problems displaying a modal view for sending emails (MFMailComposeViewController). I'm trying to display this modal view from a de开发者_运维技巧tailed view that was pushed on the stack by selecting a cell in an initial table view. My problem is that although the MFMailComposeViewController does display, I do not get the Send and Cancel buttons that I usually go with the MFMailComposeViewController view. I just get the 'Back' button of my detail view in my navigation bar.

My detail view is a subclass of UIViewController conforming to MFMailComposeViewControllerDelegate,UINavigationControllerDelegate protocols:

And my methods for sending emails is:

-(void)sendEmail {

   MFMailComposeViewController *mailComposer = [[MFMailComposeViewController alloc] init];
   mailComposer.mailComposeDelegate = self;

   if ([MFMailComposeViewController canSendMail]) {

      [mailComposer setToRecipients:[NSArray arrayWithObjects:@"test@gmail.com",nil]];
      [mailComposer setSubject:@"Subjecy"];
      [mailComposer setMessageBody:@"Body" isHTML:NO];

      [self presentModalViewController:mailComposer animated:YES];
}

     [mailComposer release];
}


- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error 
{
     [self dismissModalViewControllerAnimated:YES];

     if (result == MFMailComposeResultFailed) {
          UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Message Failed" message:@"Your message failed to send" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
          [alert show];
          [alert release];
    }
}

Many thanks for any help.


I had a similar problem when displaying the email window on an iPad with [self presentModalViewController:mailComposer animated:YES];

The Send and Cancel buttons were partially cut off because the whole window was shifted up by approximately 20 or 30 pixels. Strangely, this was only happening in Portrait mode when the home button was at the bottom.

The solution was to set the main window size to iPad Full Screen in MainWindow.XIB It was set to None by default.

Rich

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜