有很多关于如何使用iphone / ipad应用程序发送附件的教程和信息,但有预定义的图像或其他文件类型。 但是如何从我的iphone / ipad发送包含当前文件的邮件。更具体地说,来自相机的图像或图像?
干杯谢谢
答案 0 :(得分:1)
如果您使用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];
}
答案 1 :(得分:0)
MFMailComposeViewController * mailComposer = [[MFMailComposeViewController alloc]init];
mailComposer.mailComposeDelegate = self;
UIImage *myImage = // some code to get your image or what ever file you want
// make sure you can make NSData from the object
[mailComposer addAttachmentData:UIImageJPEGRepresentation(imageToShare, 1.0) mimeType:@"image/jpg" fileName:@"what ever you want to call the file"];
[self presentViewController:mailComposer animated:YES completion:nil];