Tab bar interface orientation issue
I have added a custom tab bar. With tabs including more tab.
My First tab suppor开发者_开发技巧ts only portrait mode. Second tab has all orientations.
Issue happens when selecting the second tab and keep it in landscape mode and then select first tab in landscape mode. At that time, first tab view is cleanly rotated but tab bar remains in landscape mode.
How can i overcome this scenario? This is the should rotate method in custom tab bar controller
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
if (self.selectedIndex == 0) {
return [self.selectedViewController shouldAutorotateToInterfaceOrientation:UIInterfaceOrientationPortrait];
} else if (self.selectedIndex == 1) {
return YES;
}
return NO;}
This is the should rotate method in first and second view controllers of navigation controller
First
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return (interfaceOrientation == UIInterfaceOrientationPortrait);}
Second
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return YES;}
In should autorotate to interface orientation you need to redraw the tabBar, just remove it from the self.window
and add it again.
[navigationController_.view removeFromSuperview];
[self.window addSubview:navigationController_.view];
Edit: you need to set the correct frame for every orientation before redraw.
精彩评论