I have a photo application that overlays a custom button on the camera (for taking pictures, turning the flash on / off, other ordinary things, etc.).
I want the control interface to support only portrait orientation (I'm talking only about the control button / interface, not the actual captured image), which worked fine until iOS 6.
However, upgrading to xCode 5.0 and upgrading iPad 3 to iOS 7 (GM Seed for the 3rd generation iPad), I found that the camera selection interface automatically rotates when the orientation changes. Surprisingly, I tested the same build on the iPhone 5 (updated to iOS 7), but the problem of automatic rotation did not appear.
[To be sure, I checked the same code again in iOS 6, and automatic rotation did not happen on either the iPhone or iPad].
Just to demonstrate how I process my image picker, here is a bit of code snippet:
UIImagePickerController *pickercustom = [[UIImagePickerController alloc] init]; pickercustom.sourceType = UIImagePickerControllerSourceTypeCamera; pickercustom.showsCameraControls = NO; pickercustom.wantsFullScreenLayout = YES; pickercustom.navigationBarHidden=YES; pickercustom.view.userInteractionEnabled=YES; if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) { if (IPAD.userInterfaceIdiom == UIUserInterfaceIdiomPad) { pickercustom.delegate = self; UIDevice *currentDevice = [UIDevice currentDevice]; while ([currentDevice isGeneratingDeviceOrientationNotifications]) [currentDevice endGeneratingDeviceOrientationNotifications]; [self presentViewController:pickercustom animated:YES completion:nil]; while ([currentDevice isGeneratingDeviceOrientationNotifications]) [currentDevice endGeneratingDeviceOrientationNotifications]; } else { pickercustom.delegate = self; [self presentViewController:pickercustom animated:YES completion:nil]; } }
Added "endGeneratingDeviceOrientationNotifications" to stop the rotation of the interface (which still worked fine).
I also tried adding these three methods after reading this: UIImagePickerController in iOS 6 does not work correctly
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return (interfaceOrientation == UIInterfaceOrientationPortrait); } - (BOOL)shouldAutorotate { return NO; } - (NSUInteger)supportedInterfaceOrientations { return UIInterfaceOrientationMaskPortrait; }
... but this was perhaps the specific solution of iOS 6. In my case, it did not work.
Please let me know if you can find out the reason. It would be very helpful.