I’m currently working on an iPad app to run in iOS 6
I’ve implemented a subclass of UIImagePickerController in my app that forces the camera to be in landscape orientation by overriding the - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation and - (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window functions.
There seems to be a random chance that upon launching the image picker via presentViewController it will get caught on the camera “loading” screen. The one that looks like a closed camera shutter. The app will freeze on this screen unless you exit out of it or lock/unlock the screen, after which it will function correctly.
I also have a custom UI for the camera view. However I was noticing this issue before I added that in, so I think it’s unrelated.
Here’s what I have to open the picker:
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
self.modalController = [[CameraLandscapeImagePicker alloc] init];
self.modalController.delegate = self;
self.modalController.sourceType = UIImagePickerControllerSourceTypeCamera;
self.modalController.mediaTypes = [NSArray arrayWithObjects:(NSString *) kUTTypeImage, nil];
self.modalController.allowsEditing = NO;
[self.viewController presentViewController:modalController animated:YES completion:nil];
//add the overlaying view ui
[self.modalController buildCustomOverlay];
self.newMedia = YES;
}
Any help is appreciated.
[EDIT] – Update:
I have managed to figure out how to intentionally replicate this issue. Bellow are steps:
- tap my apps “capture” button to load up the camera
- exit the camera interface
- press the home button on the ipad
- open the app again by tapping it’s icon on home screen
- tap my apps “capture” button again
- camera freezes on shutter screen
I also noticed that it occurs even when connected to xcode.
I have modified my code so that the UIImagePickerController object is provided via a singleton. Previously I was creating a new UIImagePickerController object each time. This has not had any effect and I am still getting the same issue.
I’ve left the app running on the shutter screen for about 5 minutes now and it is still stuck.
I’ve finally figured out what the problem was.
In the custom UI view that I added as the
cameraOverlayViewof theUIImagePickerI had a custom NavigationBar view.This view had it’s delegate set to the UIImagePicker and the delegate property used
retain.In the end it was a single word change from “retain” to “assign” to fix it:
If you’re having a similar issue to this I recommend commenting out parts of your custom ui code to see what exactly is causing the problem.