-1

このコードを使用してアプリケーション用に複数の写真を 1 つのメールに添付したいのですが、最後の 1 枚の写真のみをメールに添付できますが、uiimageview ですべての写真を読み取ることができます。すべての写真を 1 つのメールに添付するにはどうすればよいですか? ここに読み取り画像のコードがあります

- (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];
}

アプリがクラッシュしました

4

1 に答える 1

2

画像の取得と、質問とは関係のない UI の処理に関する大量のコードがあります (そして、アプリがクラッシュしている可能性が非常に高いです。MFMailComposeViewController の相互作用が原因でクラッシュしているようには見えません)。 . 大規模な UI のコンテキストがなければ、画像を取得する方法を理解するのは非常に困難です。

しかし、核となる質問に焦点を当てると、1 通のメールに複数の写真をどのように添付しますか?

答え:[mailControler addAttachmentData: mimeType: fileName:複数回電話してください。同じファイル名のアイテムを 2 つ送信しない限り、必要な回数だけ呼び出すことができます。

于 2013-03-09T23:18:43.350 に答える