0
votes

I have a tabBarController with 2 elements: KeyPad, List

The KeyPad- needs to be set only to portrait mode. Inside the UINavigationController - I override the methods:

- (BOOL)shouldAutorotate
{
   return NO;
}

- (NSUInteger)supportedInterfaceOrientations
{
   return UIInterfaceOrientationMaskPortrait;
}

List item starts from a RotationNavigationController - here i ve set all the rotations available. Everything seems to work ok except of one thing:

  • when navigating from List item Bar Controller (which is in Landscape) to KeyPad item bar controller - KeyPad is also in landscape mode. It seems that the 2 methods (shouldAutorotate & supportedInterfaceOrientations) are not called. How to solve this?

I;ve also added the following in viewWillApppear (inside Keypad - which extend a UIViewController)

if( [UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationLandscapeLeft || [UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationLandscapeRight){
      // Landscape - WHAT TO DO HERE?
      NSLog(@"landscape");
      }

EDIT: *Here is what I did for my problem:*

//set statusbar to the desired rotation position
[[UIApplication sharedApplication] setStatusBarOrientation:UIDeviceOrientationLandscapeLeft animated:NO];

//present/dismiss viewcontroller in order to activate rotating.
UIViewController *mVC = [[[UIViewController alloc] init] autorelease];
[self presentModalViewController:mVC animated:NO];
[self dismissModalViewControllerAnimated:NO];
1

1 Answers

0
votes

When you move from one orientation tab to another, it's shouldAutorotate is called before anything else. Since you have specified NO. It stays at it's previous orientation. I worked around this by setStatusBarOrientation in the viewWillAppear:

[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeRight];

But I will have to warn you, this changes some things, like if you are checking for orientation anywhere in your code, you will have to check the statusBarOrientation instead of the orientation of your view/viewController.