[英]UIInterfaceOrientation in UINavigationViewController
I'm having issue with auto rotating in my view which is inside a UINavitionViewController and the navigationViewcontroller is inside a tabBarViewController.我在 UINavigionViewController 内的视图中遇到自动旋转问题,而 navigationViewcontroller 在 tabBarViewController 内。
I subclassed tabBarViewController.我继承了 tabBarViewController。 The problem is the interfaceorientation works fine on the first view inside the tabViewController, but whenever I push to another view it doesn't work.问题是界面方向在 tabViewController 内的第一个视图上工作正常,但是每当我推送到另一个视图时它都不起作用。
This is a code in subclass tabBarController这是子类 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];
}
}
You have to override shouldAutorotateToInterfaceOrientation: in the view controllers for all the views in the tab bar.您必须在选项卡栏中的所有视图的视图控制器中覆盖 shouldAutorotateToInterfaceOrientation:。
If a view controller's shouldAutorotateToInterfaceOrientation: returns NO, then the tab bar will not rotate, even if the view is hidden at the time of the rotation.如果视图控制器的 shouldAutorotateToInterfaceOrientation: 返回 NO,则标签栏不会旋转,即使视图在旋转时隐藏。
You should have a UIViewController
inside a UINavigationController
inside a UITabBarController
.您应该在UITabBarController
内的UINavigationController
内有一个UIViewController
。 The rotation is decided by shouldAutorotateToInterfaceOrientation:
in your UIViewController
.旋转由 shouldAutorotateToInterfaceOrientation shouldAutorotateToInterfaceOrientation:
在您的UIViewController
中决定。 You need to override that method for every UIViewController
to return the desired value, ie, YES
if you want it to rotate and NO
if you don't want it to.您需要为每个UIViewController
覆盖该方法以返回所需的值,即,如果您希望它旋转,则为YES
,如果您不希望它旋转,则为NO
。
You shouldn't override shouldAutorotateToInterfaceOrientation:
in UINavigationController
or UITabBarController
.您不应该在UINavigationController
或UITabBarController
中覆盖 shouldAutorotateToInterfaceOrientation shouldAutorotateToInterfaceOrientation:
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.