标签栏界面方向问题

xyd*_*dev 5 iphone uitabbarcontroller uiinterfaceorientation

我添加了一个自定义标签栏.包含更多选项卡的选项卡.

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

选择第二个选项卡并将其保持在横向模式,然后在横向模式下选择第一个选项卡时会出现问题.那时,第一个标签视图干净地旋转,但标签栏保持横向模式.

我怎样才能克服这种情况?这是自定义选项卡栏控制器中的应该旋转方法

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
if (self.selectedIndex == 0) {

    return [self.selectedViewController shouldAutorotateToInterfaceOrientation:UIInterfaceOrientationPortrait];

} else if (self.selectedIndex == 1) {

    return YES;
} 

return NO;}
Run Code Online (Sandbox Code Playgroud)

这是导航控制器的第一和第二视图控制器中应该旋转的方法

第一

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return (interfaceOrientation == UIInterfaceOrientationPortrait);}
Run Code Online (Sandbox Code Playgroud)

第二

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return YES;}
Run Code Online (Sandbox Code Playgroud)

Ale*_*nte 3

如果要自动旋转到界面方向,您需要重新绘制 tabBar,只需将其从 中删除self.window并再次添加即可。

[navigationController_.view removeFromSuperview];
[self.window addSubview:navigationController_.view];
Run Code Online (Sandbox Code Playgroud)

编辑:您需要在重绘之前为每个方向设置正确的框架。