ios - MFMailComposeViewController 在 iOS 7 下不工作

标签 ios objective-c ios7

[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/

相关文章:

ios - 如何在MKMapView iOS上以编程方式显示用户位置?

objective-c - 应该释放一个对象并将其设置为nil是原子的吗?

ios - iOS 7 中导航栏的默认背景颜色是什么?

ios - 使用添加为 subview 的按钮自动调整 TableView 单元格

iOS 7 在导航的自定义动画中显示黑色背景

ios - 是什么决定了 iOS 应用程序是否在 iOS 7 中获得新外观

ios - 点击单元格时尝试显示不在窗口层次结构中的 View

iphone - iOS:如何打开有动画效果的相机?

ios - "Format string is not string literal (potentially insecure)"

ios - 如何从分组的 UITableView 的单元格中删除边框?