我想使用此代码为我的应用程序将多张照片附加到一封邮件我只能将最后一张照片附加到邮件但我可以在 uiimageview 中阅读所有照片如何将所有照片附加到一封邮件?这是读取图像的代码
- (void)elcImagePickerController:(ELCImagePickerController *)picker didFinishPickingMediaWithInfo:(NSArray *)info {
[self dismissModalViewControllerAnimated:YES];
////
if ([MFMailComposeViewController canSendMail]) {
MFMailComposeViewController * mailControler = [[MFMailComposeViewController alloc]init];
mailControler.mailComposeDelegate = self;
mailControler.modalPresentationStyle = UIModalPresentationFormSheet;
NSString *emailBody = @""; // optional
[mailControler setMessageBody:emailBody isHTML:YES];
for (UIView *v in [scrollview subviews]) {
[v removeFromSuperview];
}
CGRect workingFrame = scrollview.frame;
workingFrame.origin.x = 0;
for(NSDictionary *dict in info) {
imageview = [[UIImageView alloc] initWithImage:[dict objectForKey:UIImagePickerControllerOriginalImage]];
[imageview setContentMode:UIViewContentModeScaleAspectFit];
imageview.frame = workingFrame;
[scrollview addSubview:imageview];
[imageview release];
workingFrame.origin.x = workingFrame.origin.x + workingFrame.size.width;
NSLog(@"image %@", imageview.image);
NSData * data = UIImageJPEGRepresentation(imageview.image, 0.0);
[mailControler addAttachmentData:data mimeType:@"image/jpeg" fileName:@"Photos"];
}
[scrollview setPagingEnabled:YES];
[scrollview setContentSize:CGSizeMake(workingFrame.origin.x, workingFrame.size.height)];
}
第 2 部分去邮件
-(IBAction)actionEmailComposer
{
[self presentViewController:mailControler animated:YES completion:nil];
}
应用程序崩溃了