我添加了一个自定义标签栏。带有标签,包括更多标签。
我的第一个选项卡仅支持纵向模式。第二个选项卡具有所有方向。
选择第二个选项卡并将其保持在横向模式,然后在横向模式下选择第一个选项卡时会出现问题。那时,第一个选项卡视图被干净地旋转,但选项卡栏仍处于横向模式。
我该如何克服这种情况?这是自定义标签栏控制器中的应该旋转方法
- (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;}