gpt4 book ai didi

iphone - 从我的 iPhone 应用程序将照片附加到电子邮件

转载 作者:行者123 更新时间:2023-12-01 17:33:23 25 4
gpt4 key购买 nike

我有一个 iPhone 应用程序,它从 App 内置的相册中挑选照片。现在我想添加一个分享按钮,可以选择通过电子邮件分享这张照片,我可以通过这个代码附加一张现有的照片:

    MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
picker.mailComposeDelegate = self;

[picker setSubject:@""];


// Set up recipients
NSArray *toRecipients = [NSArray arrayWithObject:@""];
[picker setToRecipients:toRecipients];


// Attach an image to the email
NSString *path = [[NSBundle mainBundle] pathForResource:@"project existing photo" ofType:@"jpg"];
NSData *myData = [NSData dataWithContentsOfFile:path];
[picker addAttachmentData:myData mimeType:@"image/jpeg" fileName:@"photo name"];

// Fill out the email body text
NSString *emailBody = @"";
[picker setMessageBody:emailBody isHTML:NO];

[self presentModalViewController:picker animated:YES];
[picker release];

但是我需要在此代码中进行哪些更改才能将选择的相册附加到电子邮件正文中?
提前致谢。

最佳答案

使用UIImagePickerController允许用户选择图像。然后它将调用此委托(delegate)方法。

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
UIImage* image = [info objectForKey:UIImagePickerControllerOriginalImage];
NSData* data = UIImageJPEGRepresentation(image, 1.0);
// Your e-mail code here
}

关于iphone - 从我的 iPhone 应用程序将照片附加到电子邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12966944/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com