UIImagePickerController在拍摄和选择图像时会导致内存警告

时间:2012-10-19 14:51:03

标签: iphone ios uikit uiimagepickercontroller

我正在使用简单的“UIImagePickerController”来解决内存问题。 我得到两个内存警告:一个在我拍摄图像时,一个在我触摸“使用”按钮时... 最好的是,这仅仅附加在4S上(恰好是我老板的电话)。我甚至无法在其他型号的iPhone上重现此错误(在3G,3GS,4和5上测试)。

我尝试了不同的东西,这是最简单的例子,可以重现问题:

UIImagePickerController *picker = [[UIImagePickerController alloc] init];

picker.sourceType = UIImagePickerControllerSourceTypeCamera;

picker.delegate = self;

[self presentModalViewController:picker animated:YES];

[picker release];

我实现了委托方法:

- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker
{
    [picker dismissModalViewControllerAnimated:YES];
}


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

// should do something with the [[info objectForKey:UIImagePickerControllerOriginalImage] retain];

    if (picker.sourceType == UIImagePickerControllerSourceTypeCamera)
        UIImageWriteToSavedPhotosAlbum(selectedImage, nil, NULL, nil);

    [picker dismissModalViewControllerAnimated:YES];

}

有谁知道这个问题并希望解决方案?

非常感谢!

1 个答案:

答案 0 :(得分:1)

这很常见。只要您处理内存警告而不会崩溃并且有足够的空间继续运行,请不要让它驱动...