我的 iPad 应用程序有一个UIViewController调用MainViewController,它显示一个UIViewController名为ModalViewController. ModalViewController然后呈现一个UIImagePickerController.
这是MainViewController.m:
@implementation MainViewController {
...
- (BOOL)shouldAutorotate
{
return YES;
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
{
return UIInterfaceOrientationIsLandscape(toInterfaceOrientation);
}
- (NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskLandscape;
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return UIInterfaceOrientationLandscapeRight;
}
...
}
因此它可以旋转到任一横向方向,并且在ModalViewController呈现时它也会正确旋转。
但是,当UIImagePickerController它出现时,它允许旋转到横向或纵向,这允许MainViewController并ModalViewController旋转到不希望的方向。
屏幕上显示时如何防止MainViewController和ModalViewController旋转?UIImagePickerController