UIImagePickerController gives me a black preview

I use UIImagePickerController to get the image. I am 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 I accidentally get a preview in the form of a black screen, if this happens once, then it will never be restored until we destroy and restart the application.

I get the correct image from the UIImagePickerControllerDelegate , but I have this preview problem when the UIImagePickerController has the camera as the source type.

+6
source share
2 answers

If this happens by accident, I doubt it is a memory problem. The image from the UIImagePickerController is quite large. If you manage to somehow manipulate the image, your memory may not support this.

0
source

I ran into the same problem with the camera preview today, and the main reason for this problem was ... completely unrelated code in the application delegate, which changed the interface in the background.

Apparently, don't bother a lot about the fragile internal variables that AVFoundation relies on.

As soon as I excluded UI code calls from the background queues, the camera preview became fast and reliable.

This article ( http://www.cocoanetics.com/2013/02/uiview-background-queue-debugging/ ) really helped keep track of where the user interface was changed from the background queue.

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

0
source

Source: https://habr.com/ru/post/916003/


All Articles