views:

628

answers:

3

I was using UIGetScreenImage in my app, however, as everyone knows Apple is rejecting apps using private APIs. I have researched alternate ways to do this with takepicture but you get different size images as well as the annoying snapshot sound. Microsoft tag. Quickmark and Redalaser all use the UIGetScreenImage (it's obvious) but I want to do this legally. Does anyone out there have any suggestions. Much appreciated.

A: 

The best (and the slowest) thing to do is to file a feature request at Apple.

MiRAGe
+1  A: 

This might work... I think that it was the answer to another SO question.

-(UIImage *)captureView:(UIView *)view {
    CGRect screenRect = [[UIScreen mainScreen] bounds];    
    UIGraphicsBeginImageContext(screenRect.size);
    CGContextRef ctx = UIGraphicsGetCurrentContext(); 
    [[UIColor blackColor] set]; 
    CGContextFillRect(ctx, screenRect);
    [view.layer renderInContext:ctx];
    UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    return newImage; 
}
jessecurry
+1  A: 

UIGetScreenImage is currently Apple's recommended way of capturing the screen. It's sort of a private method, but they've stated in the developer forums that using it is acceptable until they add a public-API equivalent.

Update: UIGetScreenImage is no longer allowed, as of iOS 4; I believe the approved way to take pictures is now using the AVFoundation framework.

Noah Witherspoon