使用UIImagePickerControllerOriginalImage从UIImagePickerController获取图像时获取内存警告 [英] Getting memory warning while using UIImagePickerControllerOriginalImage to get image from UIImagePickerController

查看:116
本文介绍了使用UIImagePickerControllerOriginalImage从UIImagePickerController获取图像时获取内存警告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用UIImagePickerController从相机获取图像。
刚捕获图像后,使用UIImagePickerControllerOriginalImage获取内存警告。
我在iOS上使用iphone 4s。

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.

代码在这里

- (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);


}


推荐答案

<我试图用很多方法解决这些问题,但没有取得成功。
最后我改变了我的方法并使用AVCaptureSession从iPhone相机拍照
以下是Apple提供的示例代码

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.

这篇关于使用UIImagePickerControllerOriginalImage从UIImagePickerController获取图像时获取内存警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆