我的iPad应用程序有一个名为UIViewController
的{{1}},其中显示了一个名为MainViewController
的模态页面UIViewController
。 ModalViewController
然后会出现ModalViewController
。
这是 MainViewController.m :
UIImagePickerController
因此它会旋转到横向方向中的任何一个,并且当呈现@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
轮换?
答案 0 :(得分:0)
这是Stop a modal UIViewController from rotating问的问题吗?如果你最后使用UINavigationController
,你可以将它子类化并控制旋转机制