4

I've seen a number of posts on UIGetScreenImage, however, not a complete working (short) code example.

If anyone has a code example, from the prototype definition to an actual call, that would be greatly appreciated.

Bill the Lizard
  • 398,270
  • 210
  • 566
  • 880
John Muchow
  • 4,798
  • 8
  • 40
  • 40

2 Answers2

12
CGImageRef UIGetScreenImage(void);

....

    CGImageRef screen = UIGetScreenImage();
    UIImage* screenImage = [UIImage imageWithCGImage:screen];
    CGImageRelease(screen); // you need to call this. 
                           // UIGetScreenImage violates the CF memory management rules.
    // Use screenImage as you like.
kennytm
  • 510,854
  • 105
  • 1,084
  • 1,005
  • 4
    I've written a (short) complete working example that shows how to work with this method: http://iphonedevelopertips.com/user-interface/screen-capture-using-uigetscreenimage.html – John Muchow May 10 '10 at 18:21
1

Recently I needed to integrate taking screenshots into my iOS app. This question comes up pretty high in the search list on StackOverflow. However, since the initial public release of this method, Apple has made UIGetScreenImage private and any call to it will get your app rejected.

Apple made this post on their official forum regarding replacing calls to UIGetScreenImage.

Programmatic screenshots are no longer as simple as they use to be and there are now different ways to take a screenshot depending on the type of image that needs to be acquired.

The above Apple forum post explains how to take an image in each context.

RLH
  • 15,230
  • 22
  • 98
  • 182