coolio
coolio

Reputation: 419

UIImagePickerController will not initialize camera view sometimes

When I instantiate and present an UIImagePickerController, sometimes it will take up to 5 seconds for the video feed to show up and there will just be a black screen. I do instantiate the UIImagePickerController multiple times from different views. What could be the source of this problem?

Upvotes: 5

Views: 690

Answers (1)

manecosta
manecosta

Reputation: 8772

Delays on UI stuff are usualy related to code not being ran on Main Thread. Only Main Thread can change the UI, so if your code happens to run on some other background thread it will have a few seconds delay. You can guarantee a block of code will be ran on Main Thread with:

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

I've answered a similar problem here:

dismissViewControllerAnimated:completion: has a couple second delay

Upvotes: 2

Related Questions