我正在使用MFMailComposer使用此代码发送image.m
MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init]; if (picker !=nil) { picker.mailComposeDelegate = self; NSString *msgTitle; [picker setToRecipients:[NSArray arrayWithObjects:@"", nil]]; [picker setSubject:msgTitle]; [picker addAttachmentData:UIImagePNGRepresentation(imageView.image) mimeType:@"image/png" fileName:@"img"]; [self presentModalViewController:picker animated:YES];
如果我的图像尺寸为500kb,则MFMailModalView图像尺寸显示为2MB。
图片是big.i我发送图像的大小与我的代码相同。
答案 0 :(得分:1)
NSData *UIImageJPEGRepresentation(UIImage *image, CGFloat compressionQuality)
//Replace this snippet to your code
MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
if (picker !=nil) {
picker.mailComposeDelegate = self;
NSString *msgTitle;
[picker setToRecipients:[NSArray arrayWithObjects:@"", nil]];
[picker setSubject:msgTitle];
[picker addAttachmentData:UIImageJPEGRepresentation(imageView.image,0.5) mimeType:@"image/png" fileName:@"img"];
[self presentModalViewController:picker animated:YES];
该功能可帮助您压缩图像大小。