iPhone:UIImagePickerController 各种问题
各位 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 是最终尝试使用不再引用任何内容的图像的图像。
让我知道如何澄清。
非常感谢迄今为止陪伴我的所有人!
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!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是一个猜测,但我敢打赌你的内存即将耗尽并被杀死。 尝试在这一行中自动释放发送到后台的图像:
This is a guess, but I bet you're running out of memory and being killed. Try autoreleasing the image you send to the background in this line: