无法在Xcode 8中的iOS应用中发送电子邮件

时间:2016-11-11 04:44:47

标签: ios objective-c email send mfmailcomposeviewcontroller

- (IBAction)showEmail:(id)sender {
    if ([MFMailComposeViewController canSendMail]) {
        MFMailComposeViewController* composeVC = [[MFMailComposeViewController alloc] init];
        composeVC.mailComposeDelegate = self;

        // Configure the fields of the interface.
        [composeVC setToRecipients:@[@"address@example.com"]];
        [composeVC setSubject:@"Hello!"];
        [composeVC setMessageBody:@"Hello from California!" isHTML:NO];

        // Present the view controller modally.
        [self presentViewController:composeVC animated:YES completion:nil];
      // composeVC.modalPresentationStyle = UIModalPresentationPageSheet ;
    }
    else{
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Failure"
                                                        message:@"Your device doesn't support the composer sheet"
                                                       delegate:nil
                                              cancelButtonTitle:@"OK"
                                              otherButtonTitles: nil];
        [alert show];
    }
}

即使在真实设备上进行测试,它始终处于else状态。请帮忙。这适用于其他Xcode版本

0 个答案:

没有答案