I have captured image from iphone using the below UIImagePickerController delegate method.
- (void) imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
UIImage *image = [info objectForKey:@"UIImagePickerControllerOriginalImage"];
self.myImageView.image = image;
// [self performSelector:@selector(emailButtonPressed:) withObject:image afterDelay:1.0];
[self dismissModalViewControllerAnimated:YES];
}
See above emailButtonPressed method it was called by self. I want to call this in a button action.
I wrote the code below for emailButtonPressed.
- (void)emailButtonPressed:(UIImage *)image
{
MFMailComposeViewController *mailview=[[MFMailComposeViewController alloc]init]; mailview.navigationBar.tintColor=[UIColor colorWithRed:55/255.0 green:190/255.0 blue:55/255.0 alpha:1];
mailview.mailComposeDelegate=self;
// NSMutableString *subject=[NSMutableString stringWithFormat:@"%@",@"Testing"];
[mailview setSubject:@"Picture from my iPhone!"];
// NSString *email_new=@"";
[mailview setMessageBody:@"Description" isHTML:NO];
NSData *imageData = UIImagePNGRepresentation(image);
[mailview addAttachmentData:imageData mimeType:@"image/png" fileName:@"ImageName"];
[self presentModalViewController:mailview animated:YES];
}
sorry for any mistakes in my code.
Modify your
emailButtonPressedmethod as follows,Keep this method as is,
Assuming that you have declared your email button as,
Now add this method as your button target immediately after that line,
Now on tap of
emailbuttonwhatever image you have set inself.myimageview.imageinUIImagePickerControllerdelegate will be sent as an attachment.