你好 stackoverflow 的好人!
我有个问题。
我正在开发一个应用程序,它将拍摄多张照片,每次它都会放大它们,显示预览,保存它们,然后再次加载 UIImagePickerController。
但是在拍摄了大约 5 到 6 张照片后,它就死了。
我认为它快要死了,因为我设置了一个 UIImageView 并且在这么多图片之后,我设置它的 UIImage 不再引用任何东西。
我认为罪魁祸首在这里的某个地方...
有什么我做错了吗?
- (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 是最终尝试使用不再引用任何图像的图像。
让我知道如何澄清。
非常感谢到目前为止和我在一起的每一个人!