When [camera takePicture] is called before the camera is ready, it spits out this message:
UIImagePickerController: ignoring request to take picture; camera is not yet ready.
How can I know when it is ready to take a photo?
[camera isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera] always returns true, even when it’s apparently not ready.
As @djromero said there is a solution by using
AVFoundation(but not instead ofUIImagePickerController. You just useAVFoundationto get a notification back).And then, once the camera is ready you got your notification:
I have just tested it by calling
takePictureafterUIImagePickerControllerpresentation (where I got the ‘camera is not ready’ message) and right inside my notification callback, where it worked like a charm.Side-note:
[camera isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]always returnsYesbecause it only checks that there is a camera device available. As a matter of fact, Apple recommends that you always must check that this returnsYesand that you have a non nil delegate (to provide a way todismissthe picker through the standard interface) before you try to initialize and present the controller.