3

我正在使用简单的“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];

}

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

非常感谢!

4

1 回答 1

1

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

于 2012-12-05T10:39:22.247 回答