I need a way of capturing a view or the screen with everything just exactly like it appears on screen. -renderInContext: won't do that. Are there any alternatives to this?
+1
A:
Several, but start with:
UIGetScreenImage();
Which returns a CGImageRef. If you use this, note that the image is retained, and you should release it.
Edit:
Add for completeness the main other way to do this:
UIWindow *aWindow = [[UIApplication sharedApplication].windows objectAtIndex:0];
UIGraphicsBeginImageContext(aWindow.frame.size);
[[aWindow layer] renderInContext:UIGraphicsGetCurrentContext()];
UIImage *screenshot = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
Paul Lynch
2010-04-19 12:01:04
this seems to not be available on iPhone OS
dontWatchMyProfile
2010-04-19 12:47:12
It is, but you need to add a declaration for the function to remove the warning, and it doesn't work in the simulator.
Paul Lynch
2010-04-19 13:56:05
@mystify See this question: http://stackoverflow.com/questions/2213463/how-to-use-uigetscreenimage
Brad Larson
2010-04-19 21:31:16
UIGetScreenImage is not allowed anymore. I've just got an email from Apple asking to stop using this private function and use -renderInContext: (on iOs 3.x) or AV Foundation AVCaptureSession and related classes (on iOS 4).
vfn
2010-07-23 01:02:14