简体   繁体   中英

MFMailComposeViewController is not presenting itself correctly

I am having a trouble using MFMailComposeViewController.

When I click on a button, an instance of MFMailComposeViewController should present itself:

http://postimg.org/image/i24gn4oi7/

But when it does, this happens:

http://postimg.org/image/kdwm0isrl/

Here's the code:

- (IBAction)actionEmailComposer {
    MFMailComposeViewController *mc = [[MFMailComposeViewController alloc] init];
    mc.mailComposeDelegate = self;

    NSMutableArray *email = [[NSMutableArray alloc] initWithObjects:@"factto@gmail.com", nil];

    [mc setToRecipients:email];
    //[mc setSubject:@"SUBJECT_HERE"];
    [mc setMessageBody:@"Referência: \nCor:" isHTML:NO];
    mc.modalPresentationStyle = UIModalPresentationFullScreen;

    // Present mail view controller on screen
    [self presentViewController:mc animated:YES completion:NULL];
}

- (void) mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error
{
    switch (result)
    {
        case MFMailComposeResultCancelled:
            NSLog(@"Mail cancelled");
            break;
        case MFMailComposeResultSaved:
            NSLog(@"Mail saved");
            break;
        case MFMailComposeResultSent:
        {
            NSLog(@"Mail sent");
            UIAlertView *msg = [[UIAlertView alloc] initWithTitle:@"Obrigado!" message:@"Logo logo entraremos em contato!" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
            [msg show];
        }
            break;
        case MFMailComposeResultFailed:
            NSLog(@"Mail sent failure: %@", [error localizedDescription]);
            break;
        default:
            break;
    }

    [self dismissViewControllerAnimated:YES completion:NULL];
}

Actually, on the iPad it does work properly, it just happens on the iPhone! What is going on? What am I doing wrong?

Thanks in advance.

从中显示邮件视图控制器的视图控制器必须全屏显示,并且在前端,如果不是,则视图的某些部分将无法正确响应触摸和/或可见(如您所见)。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM