[英]UIInterfaceOrientation in UINavigationViewController
我在 UINavigionViewController 内的视图中遇到自动旋转问题,而 navigationViewcontroller 在 tabBarViewController 内。
我继承了 tabBarViewController。 问题是界面方向在 tabViewController 内的第一个视图上工作正常,但是每当我推送到另一个视图时它都不起作用。
这是子类 tabBarController 中的代码
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return YES;
if([self.selectedViewController isKindOfClass:[UINavigationController class]]){
return [[(UINavigationController*)self.selectedViewController visibleViewController] shouldAutorotateToInterfaceOrientation:interfaceOrientation];
} else {
return [self.selectedViewController shouldAutorotateToInterfaceOrientation:interfaceOrientation];
}
}
您必须在选项卡栏中的所有视图的视图控制器中覆盖 shouldAutorotateToInterfaceOrientation:。
如果视图控制器的 shouldAutorotateToInterfaceOrientation: 返回 NO,则标签栏不会旋转,即使视图在旋转时隐藏。
您应该在UITabBarController
内的UINavigationController
内有一个UIViewController
。 旋转由 shouldAutorotateToInterfaceOrientation shouldAutorotateToInterfaceOrientation:
在您的UIViewController
中决定。 您需要为每个UIViewController
覆盖该方法以返回所需的值,即,如果您希望它旋转,则为YES
,如果您不希望它旋转,则为NO
。
您不应该在UINavigationController
或UITabBarController
中覆盖 shouldAutorotateToInterfaceOrientation shouldAutorotateToInterfaceOrientation:
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.