arturdev arturdev - 24 days ago 72x
iOS Question

iOS 10 UIImagePickerController black screen

I'm facing a strange problem....

On devices running

iOS 10
camera preview shows black screen.

But in older version it works fine.

I'm using

self.sourceType = UIImagePickerControllerSourceTypeCamera;

My info.plist file:

enter image description here

enter image description here

Example project:


I solved this with different approach.

Don't make subclass of UIImagePickerController because Apple does not support subclass of UIImagePickerController.


The UIImagePickerController class supports portrait mode only. This class is intended to be used as-is and does not support subclassing. The view hierarchy for this class is private and must not be modified, with one exception. You can assign a custom view to the cameraOverlayView property and use that view to present additional information or manage the interactions between the camera interface and your code.

Here is alternate solution:

Add this code in UIViewController

self.imagePickerController.sourceType = UIImagePickerControllerSourceTypeCamera;
self.imagePickerController.showsCameraControls = NO;
self.imagePickerController.delegate = self;

[self.view addSubview:self.imagePickerController.view];
[self addChildViewController:self.imagePickerController];
[self.imagePickerController didMoveToParentViewController:self];

Working Fine in all iOS version and devices. :):)