Getting memory warning while using UIImagePickerControllerOriginalImage to get image from UIImagePickerController

心不动则不痛 提交于 2019-12-21 18:00:15

问题


I am using UIImagePickerController for getting image from camera. Just after I capture image and get it by using UIImagePickerControllerOriginalImage getting memory warning. I am using iphone 4s with iOS.

Code is here

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{

    [self dismissViewControllerAnimated:YES completion:nil];
    UIImage* originalImage = [info objectForKey:UIImagePickerControllerOriginalImage];

//Getting memory warning after this line
    NSData *data =UIImageJPEGRepresentation(originalImage, 0.1);


}

回答1:


I have tried to solve these problem with many ways but didn't get success. Finally I have changed my approach and used AVCaptureSession to take picture from iPhone camera Here is the sample code provided by Apple

https://developer.apple.com/library/ios/samplecode/SquareCam/Introduction/Intro.html#//apple_ref/doc/uid/DTS40011190

All is fine now no memory leaks, performance improved, capturing processes is fast.



来源:https://stackoverflow.com/questions/24822625/getting-memory-warning-while-using-uiimagepickercontrolleroriginalimage-to-get-i

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!