UIImagePickerController freezing/hanging in XCode 4.2

The UIImagePickerController docs say: “The delegate methods are responsible for dismissing the picker when the operation completes. To dismiss the picker, call the dismissModalViewControllerAnimated: method of the parent controller responsible for displaying the UIImagePickerController object.”

Following other docs, one would think the most reliable way to do this would be [[picker parentViewController] dismissModalViewControllerAnimated:YES]; (which calls dismissModalViewControllerAnimated of the parent controller).

However, in in XCode 4.2 this is no longer possible. NB. I say XCode4.2 here, and I mean XCode 4.2. This is unrelated to the iOS version, but rather the XCode version. I had code working on 4.0, 4.3 and 5.0 in XCode 4.1 which fails when built on XCode 4.2.

So instead, use whatever controller you presented the viewcontroller on to dismiss it too. [parentController dismissModalViewControllerAnimated:NO];. The old way worked pre XCode 4.2. But when you upgrade to XCode 4.2 it will suddenly return nil – causing the UIImagePickerController to not be dismissed, and thus effectively hanging.

This also seems to work, but isn’t really what the docs suggest. [picker dismissModalViewControllerAnimated:NO];.

Thanks to Omil for the tip.


One comment on “UIImagePickerController freezing/hanging in XCode 4.2

Leave a Reply

Your email address will not be published. Required fields are marked *