我添加了一个自定义标签栏。带有更多标签的标签。

我的第一个标签仅支持纵向模式。
第二个选项卡具有所有方向。

选择第二个选项卡并将其保持在横向模式,然后在横向模式下选择第一个选项卡时,会发生问题。那时,第一个标签页 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 和第二 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/

10-12 02:05