我的 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