6

I am using UIImagePickerController to take image. I'm using the following code:

UIImagePickerController* UIPicker = [[UIImagePickerController alloc] init];
UIPicker.delegate = self;
UIPicker.sourceType= UIImagePickerControllerSourceTypeCamera;
[UIPicker setCameraCaptureMode:UIImagePickerControllerCameraCaptureModePhoto];
UIPicker.allowsEditing=NO;
[self presentModalViewController:UIPicker animated:YES];
[UIPicker release];

The problem is that randomly I am getting the preview as a black screen, if it happens once then it never restores until we kill and restart the application.

I am getting correct image from UIImagePickerControllerDelegate but I have this problem with preview when UIImagePickerController has camera as source type.

Lorenzo B
  • 33,216
  • 24
  • 116
  • 190
OnkarK
  • 3,745
  • 2
  • 26
  • 33

2 Answers2

0

If it randomly happens, I doubt it's a memory issue. The image from UIImagePickerController is quite a big one. If you manage to manipulate the image somehow, your memory might not be able to support that.

boreas
  • 1,041
  • 1
  • 15
  • 30
0

I ran into this same problem with the camera preview tonight, and the root cause of the problem was … completely unrelated code in the app delegate that modified UI on a background queue.

Apparently, it doesn't take much to unsettle the fragile internal variables that AVFoundation relies on.

Once I eliminated the calls to UI code from background queues, the camera preview became fast and reliable.

This article ( http://www.cocoanetics.com/2013/02/uiview-background-queue-debugging/ ) was very helpful in tracking down where the UI was being modified from a background queue.

I also recommend that you check out the answer to this question ( iOS 7 UIImagePickerController has black preview )

Community
  • 1
  • 1
Mike Hay
  • 2,828
  • 21
  • 26