我添加了一个自定义标签栏。带有选项卡,包括更多选项卡。
“我的第一个”选项卡仅支持纵向模式。 第二个选项卡具有所有方向。
选择第二个选项卡并将其保持为横向模式,然后选择横向模式下的第一个选项卡时会出现问题。此时,第一个选项卡 View 已完全旋转,但选项卡栏仍保持横向模式。
我该如何克服这种情况? 这是自定义标签栏 Controller 中应该旋转的方法
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
if (self.selectedIndex == 0) {
return [self.selectedViewController shouldAutorotateToInterfaceOrientation:UIInterfaceOrientationPortrait];
} else if (self.selectedIndex == 1) {
return YES;
}
return NO;}
这是导航 Controller 的第一个和第二个 View Controller 中应该旋转的方法
第一
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return (interfaceOrientation == UIInterfaceOrientationPortrait);}
第二个
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return YES;}
最佳答案
如果要自动旋转到界面方向,您需要重新绘制 tabBar,只需将其从 self.window
中删除并再次添加即可。
[navigationController_.view removeFromSuperview];
[self.window addSubview:navigationController_.view];
编辑:您需要在重绘之前为每个方向设置正确的框架。
关于iphone - 标签栏界面方向问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5855312/