In my main ViewController, I generate an image from UIGraphicsGetImageFromCurrentImageContext(). The image is assigned to a UIImage, and I’ve tested it by placing in a UIImageView in the main view, so I can see it. Works just fine. However when I tap a button I’ve assigned to save it, I get the error: -3304 "Failed to encode image for saved photos."
screenshot code:
CGSize mySize = CGSizeMake(530, 350);
UIGraphicsBeginImageContext(mySize);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextTranslateCTM(context, -444, -313);
[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
// self.screenshot is a UIImage declared in .h
self.screenshot = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
Save code:
UIImageWriteToSavedPhotosAlbum(screenshot, self, @selector(imageWasSavedSuccessfully:didSaveWithError:contextInfo:), NULL);
Not sure if I’m not meeting the requirements for camera roll images, or if that method can only be used in conjunction with the UIPickerController class. Thanks for your help.
For posterity, the issue was that the image to be saved was nil.