Here is the code I'm using and I have no problems with the iPad 3. You can also confirm the use of the iPad retina in iOS Simulator. My code also saves the file in the document directory. You can change it as you see fit.
CGSize screenSize = [[UIScreen mainScreen] applicationFrame].size; CGColorSpaceRef colorSpaceRef = CGColorSpaceCreateDeviceRGB(); CGContextRef ctx = CGBitmapContextCreate(nil, screenSize.width, screenSize.height, 8, 4*(int)screenSize.width, colorSpaceRef, kCGImageAlphaPremultipliedLast); CGContextTranslateCTM(ctx, 0.0, screenSize.height); CGContextScaleCTM(ctx, 1.0, -1.0); [(CALayer*)self.view.layer renderInContext:ctx]; CGImageRef cgImage = CGBitmapContextCreateImage(ctx); UIImage *image = [UIImage imageWithCGImage:cgImage]; CGImageRelease(cgImage); CGContextRelease(ctx); CGColorSpaceRelease(colorSpaceRef); NSString *docDir = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0]; NSString *filePath = [NSString stringWithFormat:@"%@/myscreenshot.jpg", docDir]; [UIImageJPEGRepresentation(image, 1.0) writeToFile:filePath atomically:YES];
source share