UIImagePicker built with SDK 4.3 "Hangs" on iOS 4.2
Has anyone experienced a problem with UIImagePickerControllerSourceTypeCamera built with SDK 4.3 "Hanging" on devices running iOS 4.2?
In my application, users running iOS 4.3 can open UI开发者_StackOverflowImagePicker and take photos. If a user is running iOS 4.2, the UIImagePicker loads and shows the "shutter image", but the application hangs and the "shutter" never opens to display the camera's view. Screen Image here:http://dl.dropbox.com/u/20056106/ImagePicker_Stuck.png
No CrashLog is produced, because the application is just stuck in the ImagePicker. The ImagePicker's "Cancel Button" and "Camera Button" are not enabled, so there is no way to dismiss the ImagePicker.
Has anyone experienced this type of issue?
Thank you,
Curt
I had a similar problem to yours that I fixed.
In my case the hanging only occurred when running my app on the iPhone 5.0 Simulator. If I ran the app on the iPhone 4.3 Simulator UIImagePicker worked fine.
The issue was how I was dismissing the UIImagePickerController.
Original code in my UIImagePickerController delegate method
- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker
{
// Incorrect way of dismissing the uiImagepickerController
// [[picker parentViewController] dismissModalViewControllerAnimated: YES];
// Correct way of dismissing
[self dismissModalViewControllerAnimated: YES];
[picker release];
}
Update your device, or post your crash log. Try to reboot the device and close all other app from background. this should fix it.
Following on from Omil's answer, check that these two things are correct:
- Your
UIImagePickerController
's delegate is notnil
(if it'snil
, then how can you dismiss it?) - The view controller you are calling
dismissModalViewControllerAnimated
on to dismiss theUIImagePickerController
is notnil
, and the same one you presented the picker controller on in the first place withpresentModalViewController
.
The problem with XCode4.2 is it caused point 2 to start failing ([picker parentViewController]
used to be a valid way to get the parent view controller, but now it's nil), which is why Omil's fix works for that particular case.
精彩评论