UIImagePickerController run out of memory with camera source

假装没事ソ 提交于 2019-12-02 21:30:51

I had a similar issue. The way I got round it was to handle the image from the picker in a seperate thread. My problem was the main thread handling my app/UI was crashing out when trying to close the picker and handle the image:

- (void)imagePickerController:(UIImagePickerController *)picker
    didFinishPickingImage:(UIImage *)image
              editingInfo:(NSDictionary *)editingInfo
{
    [[picker parentViewController] dismissModalViewControllerAnimated:YES];

    NSLog(@"picker did finish");
    [NSThread detachNewThreadSelector:@selector(useImage:) toTarget:self withObject:image];

}
Daniel

Your problem might be due to you taking the original image.

The original image from the camera has a resolution of around 1200x1400, which is a lot of memory and will cause the device to crash if you try making a picture out of it (it will run out of memory).

I would suggest resizing the image to be smaller (the native 320x480).

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