MFMailComposeViewController中缺少邮件正文和图像附件

时间:2014-09-20 09:23:57

标签: ios cocoa-touch ios7 mfmailcomposeviewcontroller

在我的应用中,我有一个button按下时会显示一个预先填充了主题,消息正文和jpg的MFMailComposeViewController。但是,我注意到一些奇怪的行为。 MFMailComposeViewController通常会显示消息正文和图像,但有时会显示消息正文和图像附件,但主题始终正确显示。我正在iOS 8上运行我的应用。我的代码如下。任何建议/意见将不胜感激。

- (void)emailButtonPressed:(id)sender {
    MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
    picker.mailComposeDelegate = self;
    [picker setSubject:@"My Subject"];

    [picker setMessageBody:[NSString stringWithFormat:@"My Message Body"] isHTML:YES];
    NSData *imageData = UIImageJPEGRepresentation(self.image, 1.0);
    NSString *fileName = @"myFileName";
    fileName = [fileName stringByAppendingPathExtension:@"jpeg"];
    [picker addAttachmentData:imageData mimeType:@"image/jpeg" fileName:fileName];

    [self presentViewController:picker animated:YES completion:nil];
}

0 个答案:

没有答案