0

对不起,如果我错过了我昨天才开始这个 iOS 开发的东西。我有一个基本应用程序,用户最多可以拍摄 3 张图片,这些图片保存在 3 个不同的 UIImageViews 中,该应用程序还检索 gps 坐标并将它们更改为地址。

我想要做的是能够将这些图像和信息发送到电子邮件地址。

目前我有一个链接到一个动作的发送按钮。

谢谢

- (IBAction)sendFinalItem:(UIButton *)sender {
    NSLog(@"send button pressed");
    MFMailComposeViewController *mailcontroller = [[MFMailComposeViewController alloc] init];
    [mailcontroller setMailComposeDelegate:self];
    NSString *email =@"MYEMAIL@MYEMAIL.CO.UK";
    NSArray *emailArray = [[NSArray alloc] initWithObjects:email, nil];
    [mailcontroller setToRecipients:emailArray];
    [mailcontroller setSubject:@"[Urgent]Potential Job, iPhone snapped"];
    [self presentViewController:mailcontroller animated:YES completion:nil];
}

- (void) mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:         (MFMailComposeResult)result error:(NSError *)error
{
    switch (result)
     {
        case MFMailComposeResultCancelled:
         NSLog(@"Mail cancelled");
        break;
        case MFMailComposeResultSaved:
        NSLog(@"Mail saved");
        break;
        case MFMailComposeResultSent:
         NSLog(@"Mail sent");
        break;
        case MFMailComposeResultFailed:
         NSLog(@"Mail sent failure: %@", [error localizedDescription]);
        break;
        default:
       break;
     }

// Close the Mail Interface
[self dismissViewControllerAnimated:YES completion:NULL];
}
4

1 回答 1

3

用你的sendFinalItem方法写这个..

NSData *dataImage = UIImageJPEGRepresentation(yourImageViewName.image, 0.5f);
[mailer addAttachmentData:dataImage mimeType:@"image/jpeg" fileName:@"Image_1.jpg"]

希望这可以帮助。

编辑:

[mailer setMessageBody:yourTextView.text isHTML:NO];

您可以设置isHTMLYES。(如果您textview包含HTML 数据。)

编辑:

如果您想要高质量的图像,请使用UIImagePNGRepresentation(yourImageViewName.image)而不是UIImageJPEGRepresentation(yourImageViewName.image, 0.5f)

快乐的编码..

于 2013-10-11T14:49:09.593 回答