我在我的视图中遇到了自动旋转的问题,我的视图在UINavitionViewController中,而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];
}
}发布于 2011-05-31 22:53:58
您应该在UINavigationController中的UITabBarController中有一个UIViewController。旋转由UIViewController中的shouldAutorotateToInterfaceOrientation:决定。您需要为每个UIViewController重写该方法以返回所需的值,即,如果希望旋转,则返回YES;如果不希望旋转,则返回NO。
您不应该在UINavigationController或UITabBarController中重写shouldAutorotateToInterfaceOrientation:。
发布于 2011-05-31 22:39:46
您必须覆盖标签栏中所有视图的视图控制器中的shouldAutorotateToInterfaceOrientation:。
如果视图控制器的shouldAutorotateToInterfaceOrientation:返回NO,那么选项卡栏将不会旋转,即使视图在旋转时处于隐藏状态。
https://stackoverflow.com/questions/6187230
复制相似问题