【发布时间】:2015-03-12 03:35:32
【问题描述】:
我有 10 张图片被收集并导入到电子邮件中,用户将发送这些图片,但它们一直显示为附件,我需要这些图片一个接一个,而不是作为附件。我在想一个pdf,但我不知道如何生成一个...
这是我的代码:
- (IBAction)openMail:(id)sender
{
if ([MFMailComposeViewController canSendMail])
{
MFMailComposeViewController *mailer = [[MFMailComposeViewController alloc] init];
mailer.mailComposeDelegate = self;
[mailer setSubject:@"Contents Concepts Photo report"];
[mailer.view setNeedsDisplay];
NSString *path = [[NSBundle mainBundle] pathForResource:@"ContentsConceptsLogoFinal6copy" ofType:@"png"];
NSData *myData = [NSData dataWithContentsOfFile:path];
[mailer addAttachmentData:myData mimeType:@"image/png" fileName:@"photo name"];
NSString *path1 = [[NSBundle mainBundle] pathForResource:@"1" ofType:@"png"];
NSData *myData1 = [NSData dataWithContentsOfFile:path1];
[mailer addAttachmentData:myData1 mimeType:@"image/png" fileName:@"photo name"];
NSData *imageData = UIImagePNGRepresentation(self.personimgThumbNail.image);
[mailer addAttachmentData:imageData mimeType:@"image/png" fileName:@"Imageone"];
NSString *path2 = [[NSBundle mainBundle] pathForResource:@"2" ofType:@"png"];
NSData *myData2 = [NSData dataWithContentsOfFile:path2];
[mailer addAttachmentData:myData2 mimeType:@"image/png" fileName:@"photo name"];
NSData *imageDatatwo = UIImagePNGRepresentation(self.personimgThumbNailtwo.image);
[mailer addAttachmentData:imageDatatwo mimeType:@"image/png" fileName:@"Imagetwo"];
NSString *path3 = [[NSBundle mainBundle] pathForResource:@"3" ofType:@"png"];
NSData *myData3 = [NSData dataWithContentsOfFile:path3];
[mailer addAttachmentData:myData3 mimeType:@"image/png" fileName:@"photo name"];
NSData *imageDatathree = UIImagePNGRepresentation(self.personimgThumbNailthree.image);
[mailer addAttachmentData:imageDatathree mimeType:@"image/png" fileName:@"Imagethree"];
NSString *path4 = [[NSBundle mainBundle] pathForResource:@"4" ofType:@"png"];
NSData *myData4 = [NSData dataWithContentsOfFile:path4];
[mailer addAttachmentData:myData4 mimeType:@"image/png" fileName:@"photo name"];
NSData *imageDatafour = UIImagePNGRepresentation(self.personimgThumbNailfour.image);
[mailer addAttachmentData:imageDatafour mimeType:@"image/png" fileName:@"Imagefour"];
NSString *path5 = [[NSBundle mainBundle] pathForResource:@"5" ofType:@"png"];
NSData *myData5 = [NSData dataWithContentsOfFile:path5];
[mailer addAttachmentData:myData5 mimeType:@"image/png" fileName:@"photo name"];
NSData *imageDatafive = UIImagePNGRepresentation(self.personimgThumbNailfive.image);
[mailer addAttachmentData:imageDatafive mimeType:@"image/png" fileName:@"Imagefive"];
NSString *path6 = [[NSBundle mainBundle] pathForResource:@"6" ofType:@"png"];
NSData *myData6 = [NSData dataWithContentsOfFile:path6];
[mailer addAttachmentData:myData6 mimeType:@"image/png" fileName:@"photo name"];
NSData *imageDatasix = UIImagePNGRepresentation(self.personimgThumbNailsix.image);
[mailer addAttachmentData:imageDatasix mimeType:@"image/png" fileName:@"Imagesix"];
NSString *path7 = [[NSBundle mainBundle] pathForResource:@"7" ofType:@"png"];
NSData *myData7 = [NSData dataWithContentsOfFile:path7];
[mailer addAttachmentData:myData7 mimeType:@"image/png" fileName:@"photo name"];
NSData *imageDataseven = UIImagePNGRepresentation(self.personimgThumbNailseven.image);
[mailer addAttachmentData:imageDataseven mimeType:@"image/png" fileName:@"Imageseven"];
NSString *path8 = [[NSBundle mainBundle] pathForResource:@"8" ofType:@"png"];
NSData *myData8 = [NSData dataWithContentsOfFile:path8];
[mailer addAttachmentData:myData8 mimeType:@"image/png" fileName:@"photo name"];
NSData *imageDataeight = UIImagePNGRepresentation(self.personimgThumbNaileight.image);
[mailer addAttachmentData:imageDataeight mimeType:@"image/png" fileName:@"Imageeight"];
NSString *path9 = [[NSBundle mainBundle] pathForResource:@"9" ofType:@"png"];
NSData *myData9 = [NSData dataWithContentsOfFile:path9];
[mailer addAttachmentData:myData9 mimeType:@"image/png" fileName:@"photo name"];
NSData *imageDatanine = UIImagePNGRepresentation(self.personimgThumbNailnine.image);
[mailer addAttachmentData:imageDatanine mimeType:@"image/png" fileName:@"Imagenine"];
NSString *path10 = [[NSBundle mainBundle] pathForResource:@"10" ofType:@"png"];
NSData *myData10 = [NSData dataWithContentsOfFile:path10];
[mailer addAttachmentData:myData10 mimeType:@"image/png" fileName:@"photo name"];
NSData *imageDataten = UIImagePNGRepresentation(self.personimgThumbNailten.image);
[mailer addAttachmentData:imageDataten mimeType:@"image/png" fileName:@"Imageten"];
[self presentModalViewController:mailer animated:YES];
}
}
【问题讨论】:
-
为什么图片不显示为附件?您正在将它们添加为附件。
-
因为我需要它们以报告样式显示。