views:

21

answers:

1

Hello experts!

My situation is like this, I want to programmatically take a print screen of the current view visible to the user and save this to the photo album. The problem is that I don't want all of the views in the hierarchy to be visible. My plan was to:

  1. Make a copy of the view hierarchy.
  2. Hide the subviews which were not interesting.
  3. Take the print screen.
  4. Save it to the photo album.

The problem is that I'm stuck on the first point. Since UIView does not implement the NSCopying protocol I can't make a deep copy of the view hierarchy. I tried archiving and unarchiving the views but this was only available on the dektop.

As I see it there there are two options here:
a) Implement the NSCopying protocol on all the views and subviews. b) Fade a white view covering the whole screen (sort of like the flash-effect when you take a print screen manually) and in that instant I hide the views I want.

Is there some other way of approaching this problem that I have missed?

Edit:

    UIGraphicsBeginImageContext([[wordManager mainWorkViewController] view].frame.size);  
    [[[[wordManager mainWorkViewController] view] layer] renderInContext:UIGraphicsGetCurrentContext()];   
    UIImage *screenshot = UIGraphicsGetImageFromCurrentImageContext();    
    UIGraphicsEndImageContext();

Best regards //Abeansits

A: 

So, unfortunately no one was able to provide any help on this matter. How I solved the problem:

I removed the elements which I did not want in the print screen. I did this using animations so there would be no graphical flicker. In the end it looked pretty good, to bad I never solved the original problem.

Please post a fix if any one finds one. Best regards

//Abeansits

ABeanSits