Reputation: 41
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:
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.
Upvotes: 2
Views: 3598
Reputation: 73
I was having this problem, and already had a weak property for the delegate (also tried using assign), yet the problem persisted.
I found my problem was assigning directly the UIImagePickerController
's cameraOverlayView
like so:
self.picker.cameraOverlayView = self.overlay;
changing it to the following worked
[self.picker.cameraOverlayView addSubview:self.overlay];
I found the solution in an Apple sample app:
EDIT After further testing, I found this was actually not enough.
As suggested in this post: Displaying UIImagePickerController within another UIView
I added the following to get the shutter animation to "open":
[self.picker viewWillAppear:YES];
[self presentViewController:self.picker animated:NO completion:nil];
[self.picker viewDidAppear:YES];
Upvotes: 0
Reputation: 41
I've finally figured out what the problem was.
In the custom UI view that I added as the cameraOverlayView
of the UIImagePicker
I 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:
@property (nonatomic,assign) id delegate;
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.
Upvotes: 2