2011-05-02 68 views
5

我已经添加了一个自定义标签栏。包含更多选项卡的选项卡。标签栏界面方向问题

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

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

我该如何克服这种情况? 这是应在自定义标签栏控制器旋转方法

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

    return [self.selectedViewController shouldAutorotateToInterfaceOrientation:UIInterfaceOrientationPortrait]; 

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

    return YES; 
} 

return NO;} 

这是在导航控制器

首先第一和第二视图控制器应该旋转方法

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { 
return (interfaceOrientation == UIInterfaceOrientationPortrait);} 

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { 
return YES;} 
+0

保持横向的标签栏是自定义的吗?你是如何添加到屏幕上的? – 2011-05-02 10:48:59

+0

@Terente Ionut Alexandru \t \t navigationController_ = [[UINavigationController alloc] initWithRootViewController:tabBarController_]; \t [self.window addSubview:navigationController_.view]; – xydev 2011-05-03 08:48:32

回答

3

In should autorotate to int您需要重新绘制tabBar,然后将其从self.window中删除并重新添加。

[navigationController_.view removeFromSuperview]; 
[self.window addSubview:navigationController_.view]; 

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

+0

无话...它工作正常... :) +1 – xydev 2011-05-03 11:15:36

+0

再次感谢.. – xydev 2011-05-03 11:22:26