我正在使用 UITabBarController,我的应用程序支持纵向和横向旋转。在启动应用程序时,我显示了一个模态视图,但我需要将该模态视图固定为仅纵向。我不知道该怎么走,类似的线程听到建议子类化并覆盖supportedInterfaceOrientations
and shouldAutorotate
,控制器是UIViewController
子类,模态视图是UIView
子类。
相关代码:
-(BOOL)shouldAutorotate{
//here I tried to test whether the modal is still visible on the screen and return no in such case, but doesn't seems to work.
return YES;
}
- (NSUInteger)supportedInterfaceOrientations{
return UIInterfaceOrientationMaskAll;
}
iOS 目标:5.0