0
我是iphone开发新手。我在视图中创建了一个按钮。点击按钮时,它会从iPhone中加载光子库。现在我想通过邮件附加这些选定的图像。我不知道如何在MFMailComposerView中附加图像。我怎样才能通过iPhone中的邮件附加iphone图像
我怎样才能做到这一点,
这里我的代码,
-(IBAction) Pictures:(id)sender
{
self.imgpicker = [[UIImagePickerController alloc] init];
self.imgpicker.delegate = self;
self.imgpicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
[self presentModalViewController:self.imgpicker animated:YES];
}
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)img1 editingInfo:(NSDictionary *)editInfo {
[[picker parentViewController] dismissModalViewControllerAnimated:NO];
UIView *view = [[UIView alloc] init]; (This view for displaying the images)
imageview = [[UIImageView alloc] initWithImage:img1];
[imageview setFrame:CGRectMake(0, 0, 320, 420)];
[self.view addSubview:imageview];
[view release];
UIBarButtonItem *rightbutton = [[UIBarButtonItem alloc] initWithTitle:@"Email" style:UIBarButtonItemStyleBordered target:self action:@selector(rightbutton)];
self.navigationItem.rightBarButtonItem = rightbutton;
[rightbutton release];
}
-(void) rightbutton
{
[self emailImage:(UIImage *)image];(how to pass the image to mail view)
}
- (void)emailImage:(UIImage *)image
{
picker = [[MFMailComposeViewController alloc] init];
picker.mailComposeDelegate = self;
[picker setToRecipients:[NSArray arrayWithObjects:@"[email protected]",nil]];
NSData *data = UIImagePNGRepresentation(image);
[picker addAttachmentData:data mimeType:@"image/png" fileName:@"iPod Library Image"];
[self presentModalViewController:picker animated:YES];
[picker release];
}
请帮助我。
谢谢。
一眼就看不出代码有什么问题(我的应用程序使用UIImagePNGRepresenation的方式与您的相同)。究竟发生了什么问题? – 2010-04-03 10:42:57
如何将图像从didFinishPickingImage方法发送到右键方法。以便我可以将图像传递给邮件。 – Pugal 2010-04-03 11:03:58