iOS 7 UIImagePickerController has black preview

During one of my recent projects I had this same (or similar) issue, namely the Camera preview showing a black screen when using UIImagePickerController on iOS7 (iPad).

What I discovered is that GCD in itself is not the problem. The problem occurs when you try to use anything at all from the UIKit framework in a thread other than the main thread (as part of an NSOperation).

First of all, let me start by saying that it is clear to me that you shouldn't do this to begin with. In my specific case, however, I had no choice. Since I think that there's a good chance that other people might be experiencing the same weird UIImagePickerController camera behaviour with the same cause, I made up some very simple example code explaining what's going on.

You can find it here: https://github.com/idamediafoundry/CameraTest

The ViewController shows 2 simple buttons. One calls UIImagePickerController, showing the camera, the other starts some GCD operations doing a simple task. If you just open the camera, everything works fine. If you first start the operations and then open the camera, the black preview issue occurs.

Again, you shouldn't call UIKit in anything but the main thread. But I don't think it's normal that breaking this rule causes the camera to malfunction when opening it later in the main thread as part of a completely different flow, right?

Hope this helps.


There doesn't seem to be a good answer to this anywhere online, so I had to slog through this myself to figure it out.

I'm using ARC (like probably most others these days), so the answer above didn't really help me.

This black camera issue happens as a side effect of doing UIKit stuff off of the main thread on iOS 7. Broadly, background UIKit operations results in all sorts of weird things happening on iOS 7 (memory not being deallocated promptly, weird performance hitches, and the black camera issue).

To prevent this, you need to not do ANY UIKit stuff on background threads.

Things you cannot do on background threads: - Allocate/initialize UIViews and subclasses - Modify UIViews and subclasses (e.g., setting frame, setting .image/.text attributes, etc).

Now, the problem with doing this stuff on the main thread is that it can mess with UI performance, which is why you see all these iOS 6 "background loading" solutions that DO NOT work optimally on iOS 7 (i.e., causing the black camera issue, among other things).

There are two things that I did to fix performance while preventing the ill effects of background UIKit operations: - Pre-create and initialize all UIImages on a background thread. The only thing you should be doing with UIImages on the main thread is setting "imageView.image = preloadedImageObject;" - Re-use views whenever possible. Doing [[UIView alloc] init] on the main thread can still be problematic if you're doing it in a cellForRowAtIndex or in another situation where responsiveness is super important.

Best of luck! You can test how you're doing by monitoring memory usage while your app is running. Background UIKit => rapidly escalating memory usage.


I had this same issue, but the app would never show the alert to grant permission to access the photos, and it would never show up in Settings->Privacy->Photos as having asked for permission. It would simply display the black screen without a permission prompt.

I finally traced this to the info.plist.

enter image description here

As it turns out if you add the key "Bundle display name" to the info.plist and leave the value blank the permission alert will never display. It seems the permissions alert pulls this value to display in the alert, and if you leave it blank it simply will not show the alert.

If you have this in your plist without a value it could be causing a black preview.

EDIT: I was experiencing this issue with some devices and not others, with my testing all 3 of the iPhone 6 devices I tested with and the iPhone 5s would not show the alert and would hang on the black screen. An iPhone 4s and iPhone 6S+ showed the alert and worked as expected.