1

I have to create application with two UIWindow (please, don't ask why). First UIWindow's rootViewController supports all orientations. Second one - only portrait and upside down. So application delegate code looks like:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    // part one
    self.windowOne = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
    self.windowOne.rootViewController = [[ViewControllerOne alloc] init]; // supports all orientations
    self.windowOne.rootViewController.view = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"image1.png"]] autorelease];

    [self.windowOne makeKeyAndVisible];
    //~part one
    // part two
    self.windowTwo = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
    self.windowTwo.rootViewController = [[ViewControllerTwo alloc] init]; // supports only portrait and upside down
    self.windowTwo.rootViewController.view = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"image2.png"]] autorelease];

    [self.windowTwo makeKeyAndVisible];
    //~part two
    return YES;
}

If only one of two parts is active (second one is commented) - everything is ok. But if windowOne has become key and visible before windowTwo, windowTwo rotates as ViewControllerTwo allows, but status bar behaves really weird: it rotates like windowOne is key and visible.

Is there any option to make status bar rotating as ViewControllerTwo says?

TridenT
  • 4,879
  • 1
  • 32
  • 56
Orange
  • 553
  • 3
  • 20

1 Answers1

1

Albeit its a hack to me but what you could try is the following:

In your view controllers shouldAutorotateToInterfaceOrientation (for iOS5) or shouldAutorotate (as for iOS6) method add the following code line:

[[UIApplication sharedApplication] setStatusBarOrientation: interfaceOrientation animated: YES];

and test out how the app behaves after that.

to get the interface-orientation in the (new for iOS6) shouldAutorotate method do the following:

UIInterfaceOrientation interfaceOrientation = [[UIDevice currentDevice] orientation];

I didn't test this all out for myself, but it could work.

(Check out some post on how to support autorotation under iOS6)

Community
  • 1
  • 1
Nenad M
  • 3,055
  • 20
  • 26
  • Thanks for reply. Have tried, but result behavior is not stable. Sometimes, status bar appears on side, not only on top or bottom. – Orange Oct 23 '12 at 13:50
  • Hm, what you could try additionally is to put the setStatusBarOrientation code also in your controllers viewWillAppear/viewDidAppear methods. But in the end this all doesn't feel like best-practice to me. – Nenad M Oct 23 '12 at 14:04
  • Issues occurs not on appear/disappear, but on fast device rotation when view is already visible. Seems like described situation is undocumented behavior. – Orange Oct 23 '12 at 14:32