I have a very strange behavior:
- in iOS 5 I present the
UIImagePickerController
as follows:
imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
imagePicker.modalPresentationStyle = UIModalPresentationFullScreen;
imagePicker.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
[self presentModalViewController:imagePicker animated:YES];
now in iOS 6 it crashes. I resolved the failure by writing a category on the UIImagePickerController
:
@implementation UIImagePickerController (NonRotating) - (BOOL)shouldAutorotate { return NO; } - (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation { return UIInterfaceOrientationMaskPortrait; } - (NSUInteger)supportedInterfaceOrientations { return UIInterfaceOrientationMaskAll; } @end
The problem is that now the UIImagePickerController
does not rotate and displays up. Moreover, when I click the Cancel button and the collector is fired, the application crashes again.
- If I use the
UIImagePickerController
inside a UIPopoverController
, everything works fine (this is because the popover does not rotate), but when I reject popover ALL the view controller in my application stops responding to rotation events , and this means that the whole application is locked in this orientation. To restore the correct behavior, I need to close the application from the background and reopen.
This is the code I use to display popover
_cameraPopoverController = [[UIPopoverController alloc] initWithContentViewController:imagePicker]; [_cameraPopoverController presentPopoverFromRect:_takeFromCamera.frame inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
This problem is driving me crazy!
source share