gpt4 book ai didi

ios - 发送带有相机图像附件的邮件

转载 作者:行者123 更新时间:2023-11-29 03:28:12 27 4
gpt4 key购买 nike

有很多教程和信息介绍如何使用您的 iphone/ipad 应用程序发送附件,但使用预定义的图像或其他文件类型。但是我如何从我的 iphone/ipad 发送带有当前文件的邮件。更具体地说,是图像还是来自相机的图像?

干杯,谢谢

最佳答案

如果您使用 UIImagePickerController 来捕获图像,则与捕获图像时相比:

  #import <MobileCoreServices/UTCoreTypes.h> // framework MobileCoreServices.framework

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
NSString *mediaType = [info objectForKey:UIImagePickerControllerMediaType];
if ([mediaType isEqualToString:(NSString *)kUTTypeImage])
{
UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage];
[self sendMailWithImage:image];
}
[picker dismissModalViewControllerAnimated:NO];
}

- (void)sendMailWithImage:(UIImage *)image
{
MFMailComposeViewController * mailComposer = [[MFMailComposeViewController alloc]init];
mailComposer.mailComposeDelegate = self;
// make sure you can make NSData from the object
[mailComposer addAttachmentData:UIImageJPEGRepresentation(image, 1.0) mimeType:@"image/jpg" fileName:@"what ever you want to call the file"];
[self presentViewController:mailComposer animated:YES completion:nil];
}

关于ios - 发送带有相机图像附件的邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20173935/

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