Hello wonderful people of stackoverflow!
I have a problem.
I am working on an app that will take multiple photos and each time it will enlarge them, show a preview, save them, and then load the UIImagePickerController again.
But after taking about 5 to 6 pictures it dies.
I think that it is dying because I have a UIImageView that I set and after so many pictures the UIImage that I set it with is no longer referencing anything.
I think that the culprit is somewhere in here...
Is there something that I am doing wrong?
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
[backgroundImage setImage: [[UIImage alloc] initWithCGImage:[[info objectForKey:UIImagePickerControllerOriginalImage] CGImage]]];
[backgroundImage setTransform:CGAffineTransformRotate(CGAffineTransformMakeScale(zoom/3, zoom/3), 1.570796327)];
UIGraphicsBeginImageContext([backgroundView bounds].size);
CGContextRef ctx = UIGraphicsGetCurrentContext();
CGContextFillRect(ctx, [backgroundView bounds]);
[backgroundView.layer renderInContext:ctx];
UIImage* screenImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
UIImageWriteToSavedPhotosAlbum(screenImage, self, @selector(ImageDidSave:didFinishSavingWithError:contextInfo:), nil);
[self dismissModalViewControllerAnimated:YES];
}
backgroundImage is the one that eventually tries to use an image that is no longer referencing anything.
Let me know how I can clarify.
Thank you very much everyone who stayed with me this far!