My iPad app has a UIViewController called MainViewController which presents a modal page sheet UIViewController called ModalViewController. ModalViewController then presents a UIImagePickerController.
Here is MainViewController.m:
@implementation MainViewController {
...
- (BOOL)shouldAutorotate
{
return YES;
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
{
return UIInterfaceOrientationIsLandscape(toInterfaceOrientation);
}
- (NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskLandscape;
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return UIInterfaceOrientationLandscapeRight;
}
...
}
So it rotates to either of the landscape orientations, and when ModalViewController is presented it rotates that correctly also.
However when the UIImagePickerController is presented, it allows rotation to landscape or portrait orientations, and this allows MainViewController and ModalViewController to rotate to un-desired orientations.
How can I prevent MainViewController and ModalViewController from rotating when the UIImagePickerController is on the screen?