MFMailComposer sending attached image size increased
i'm using MFMailComposer to send an image.m using this code
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];
if my image size is 500kb in MFMailModalView image size shows 2MB.
images is to big.i am send image only in the same size as in my code.
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];
该功能将帮助您压缩图像的大小。
链接地址: http://www.djcxy.com/p/84308.html上一篇: switch语句如何工作?