I'm working on an app and I would like to send, when I press a button, 2 screenshots of 2 views, attached it to an e-mail.
The two view controllers are called secondViewController
and commenViewController
Currently I'm using this code:
- (void)buttonPress:(id)sender {
UIGraphicsBeginImageContext(self.view.frame.size);
[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage * image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
NSData * imageData = UIImageJPEGRepresentation(image, 1.0);
if ( [MFMailComposeViewController canSendMail] ) {
MFMailComposeViewController * mailComposer = [[[MFMailComposeViewController alloc] init] autorelease];
mailComposer.delegate = self;
[mailComposer addAttachmentData:imageData mimeType:@"image/jpeg" fileName:@"attachment.jpg"];
/* Configure other settings */
[self presentModalViewController:mailComposer animated:YES];
}
}
Which works fine for my first view, but I don't know how to take, in that action, a screenshot of my commenViewController
and attach it to the mail as well...