title: in app screenshot and load into email from different view controller
body: <p>I want to take a screenshot of one of my view controller and load it into an email. The problem I am having is that I can take a screenshot of the current view controller but I wish to take the short of a separate view controller. </p>
  
  <pre><code>- (IBAction)showEmail:(id)sender
  {
  UIGraphicsBeginImageContext(self.view.frame.size);
  [self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
  UIImage * image = UIGraphicsGetImageFromCurrentImageContext();
  UIGraphicsEndImageContext();
  
  NSData *example = UIImageJPEGRepresentation(image, 1.0);
  
  // Email Subject
  NSString *emailTitle = @"Test";
  // Email Content
  NSString *messageBody = @"Attached below is the snapshot of the view controller";
  // To address
  NSArray *toRecipents = [NSArray arrayWithObject:@"testemail@hotmail.co.uk"];
  
  //    UIImage *UIImageToSend;
  MFMailComposeViewController *mc = [[MFMailComposeViewController alloc] init];
  mc.mailComposeDelegate = self;
  [mc setSubject:emailTitle];
  [mc setMessageBody:messageBody isHTML:NO];
  [mc setToRecipients:toRecipents];
  [mc setModalTransitionStyle:UIModalTransitionStyleCrossDissolve];
  //  NSData *data = UIImageJPEGRepresentation(UIImageToSend,1);
  
  //UIImage *myImage = [UIImage imageNamed:@"example.png"];
  //NSData *mageData = UIImagePNGRepresentation(myImage);
  
  [mc addAttachmentData:example  mimeType:@"image/png" fileName:@"example.png"];
  // Present mail view controller on screen
  
  [self presentViewController:mc animated:YES completion:NULL];
  }
  
  - (void) mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error
  {
      switch (result)
      {
          case MFMailComposeResultCancelled:
              NSLog(@"Mail cancelled");
              break;
          case MFMailComposeResultSaved:
              NSLog(@"Mail saved");
              break;
          case MFMailComposeResultSent:
              NSLog(@"Mail sent");
              break;
          case MFMailComposeResultFailed:
              NSLog(@"Mail sent failure: %@", [error localizedDescription]);
              break;
          default:
              break;
      }
  
      // Close the Mail Interface
      [self dismissViewControllerAnimated:YES completion:NULL];
  
  }
  </code></pre>
  
  <p>I have tried changing the self in</p>
  
  <p><code>[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];</code></p>
  
  <p>to the other view controller class name but xcode then gives me an error that says</p>
  
  <p>property of 'view' not found on object of type 'otherViewController'</p>