问题描述
我正在使用UIImagePickerController,以便让用户通过拍摄新照片或从图库中选择图像来选择我的应用中的图像。使用图库,该应用程序工作正常。但是如果我使用相机作为源,应用程序会占用大量内存,最终会在变得非常慢后被杀死。
I am using the UIImagePickerController in order to let the user select an image in my app by either taking a new pic or selecting an image from the gallery. Using gallery, the app works fine. But if I use the camera as a source, the app uses up a lot of memory and eventually gets killed after becoming terribly slow.
有人可以告诉我最佳方式使用UIImagePickerControllerSourceTypeCamera。
Can someone please tell me the optimum way to use UIImagePickerControllerSourceTypeCamera.
这是我正在使用的代码
if(![UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])
return;
picker = [[UIImagePickerController alloc] init];
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
picker.delegate = self;
[[self navigationController] presentModalViewController:picker animated:YES];
[picker release];
推荐答案
UIImagePickerController泄漏内存,如上所述以及7或8次使用后导致您的应用崩溃。您需要在应用程序的生命周期中创建单例UIImagePickerController以避免此Apple缺陷。
The UIImagePickerController leaks memory, as noted hereand after 7 or 8 uses causes your app to crash. You need to create a singleton UIImagePickerController for the life of your application to avoid this Apple defect.
这篇关于UIImagePickerControllerSourceTypeCamera占用内存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!