[MFMailComposeViewController canSendMail]
在 iOS 6 应用程序下运行良好,但在 iOS7 下运行失败。
iOS 6 邮件功能:
if ([MFMailComposeViewController canSendMail])
{
MFMailComposeViewController *mailer = [[MFMailComposeViewController alloc] init];
mailer.mailComposeDelegate = self;
[mailer setSubject:@"A Message from Bloomingkids"];
NSArray *toRecipients = [NSArray arrayWithObjects:@"support@bloomingkids.com", nil];
[mailer setToRecipients:toRecipients];
UIImage *myImage = [UIImage imageNamed:@"bloomingKidsLogo.png"];
NSData *imageData = UIImagePNGRepresentation(myImage);
[mailer addAttachmentData:imageData mimeType:@"image/png" fileName:@"Images"];
NSString *emailBody = @"Have you seen the Bloomingkids web site?";
[mailer setMessageBody:emailBody isHTML:NO];
[self presentViewController:mailer animated:YES completion:nil];
}
else
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Failure"
message:@"Your device doesn't support the composer sheet"
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles: nil];
[alert show];
}
注意:它可以在模拟器上运行,但不能在 iPad 上运行。错误是您的设备不支持 composer sheet
最佳答案
在您的设备中添加任何电子邮件帐户意味着设置一个电子邮件帐户...
关于ios - MFMailComposeViewController 在 iOS 7 下不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20560584/