Hi,
I am new to iphone development. I have created a button in the view. On clicking the button it loads the photolibrary from the Iphone. Now i want to
attached the those selected image through mail. I donno how can i
attached the image in MFMailComposerView.
How can i achieve this,
Here my code is,
-(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]***;(I donno how to pass the image instance 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];
}
Plese help me out.
Thanks.