我读过帖子说 `MFMailComposeViewController 如果它是 1 页文档,则应该显示您附加的 PDF,但由于某种原因,我的 PDF 总是显示为一个图标。我希望它显示 PDF,因为它只有 1 页。PDF 似乎很好,因为我可以发送电子邮件,并且可以在邮件应用程序或计算机上打开它。
在 iOS 6.0 或更高版本中默认情况下是否未启用此功能,还是缺少某些内容?
MFMailComposeViewController* controller = [[MFMailComposeViewController alloc] init];
controller.mailComposeDelegate = self;
// create the message body.
NSMutableString *body = [[NSMutableString alloc] init];
// add the user name to the email body.
[body appendFormat:@"Name: %@", userName];
// add the pdf to the email.
NSData *data = [NSData dataWithContentsOfFile:path];
[controller addAttachmentData:data mimeType:@"application/pdf"
fileName:@"test.pdf"
includeExtension:YES]];
// add the body string to the email body.
[controller setMessageBody:body isHTML:NO];
// show the email controller.
[self presentViewController:controller animated:YES completion:nil];