UIImagePickerController will not initialize the camera view sometimes

When I create an instance of the UIImagePickerController and present the UIImagePickerController, sometimes it takes up to 5 seconds to display the video stream and there will only be a black screen. I create an instance of UIImagePickerController several times from different views. What could be the source of this problem?

+5
source share
1 answer

Delays in the user interface are usually due to the fact that the code does not run in the main theme. Only the main thread can change the user interface, so if your code runs on some other background thread, it will have a delay of several seconds. You can guarantee that the code block will be launched in the main topic with:

dispatch_async(dispatch_get_main_queue(), ^{
    // Your code
});

I answered a similar problem:

cancelViewControllerAnimated: completion: has a couple of second delay

+2
source

All Articles