开发者

MFMailComposeViewController Not Working in Landscape

My app uses landscape mode. When trying to integrate MFMailComposeViewController that always worked for me in my other portrait mode apps, I came across the issue of mail controller not showing up at all. I found a lot of info during research and I tried to overwrite MFMailComposeViewController like it suggests here:

mfmailcomposeviewcontroller in landscape

However, it still acts the same way. In short, my View-based app has a main controller A and other controllers B and C, for example. B is open on top of A and it has the MFMailComposeViewController which, when running, hides B and goes back to A.

This is very strange but I feel like it has to do with view hierarchy and where exactly I need to add MFMailComposeViewController. When overwritten (as in a link above), this code does not resolve my problem:

MailCompose *controller = [[MailCompose alloc] init];
controller.mailComposeDelegate = self;

I appreciate any additional suggestions.

Here is the code I am using:

if ([MFMailComposeViewController canSendMail]){

    MailCompose *picker = [[MailCompose alloc]init];


    //MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];//was bef开发者_如何学Core I subclassed
    picker.mailComposeDelegate = self;

    [picker setToRecipients:[NSArray arrayWithObject:@"info@site.com"]];
    [picker setSubject:@"Feedback"];

    [picker setMessageBody:emailBody isHTML:YES];

    picker.navigationBar.barStyle = UIBarStyleBlack;

    [self presentModalViewController:picker animated:YES];
    [picker release];
}


The code you have for calling the composer looks spot on, but you already know that. So it can only be something like:

  • the code is never called
  • the device isn't sending mail

(these two can be checked with the debugger)

  • you are presenting this view from the wrong place, eg from a view that is already presenting a modal view controller (didn't know if this was possible?)
  • you have added a new window to the app at alert or status bar level, this will obscure the composer when it is presented.

Bit of a set of guesses, I hope one of them works for you!

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜