Windows Rotation Multiple Issue - iPhone / iPad

My application uses 2 UIWindows. The first shows a TabBar with ViewControllers, which only rotates in the Portrait direction. Everything is fine here.

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

In another window, I have a UIViewController that rotates to all orientations.

The problem is that when I show the second window

 [secondWindow makeKeyAndVisible]; 

And then go back to the first

 [firstWindow makeKeyAndVisible]; 

The status bar rotates in all directions, and the event should not be triggered. How can i solve the problem?

+6
iphone rotation uiwindow
source share
2 answers

It's nice to have multiple UIWindows in the same application, but here's the caveat: Apple code seems to check every UIWindow you have, and see if the topmost view controller allows for a specific rotation. If any of these windows allows rotation, your status bar will rotate regardless of whether the UIWindow is frontal or visible.

In my own application, I hide a UIWindow, which I do not use, and add an isHidden check to the corresponding UIViewControllers to prevent rotation if the window is currently hidden.

+4
source share

It's nice to have multiple UIWindows in one application, but here it should be pointed out that the Apple code seems to check every UIWindow that you have, and see if the top view controller allows a certain rotation.

Many tests answered and came to the conclusion that the rotation of the status bar depends on the very top view of the controller of each window.

+1
source share