My app uses 2 UIWindows. The first shown has a TabBar controller with ViewControllers that only rotate to Portrait orientations. Up to here everything woks fine.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return (UIInterfaceOrientationIsPortrait(interfaceOrientation));
}
On the other window I have a UIViewController that rotates to all orientations.
The problem is that when I show the second window
[secondWindow makeKeyAndVisible];
And then return to the first one
[firstWindow makeKeyAndVisible];
The statusbar rotates to all directions and the event shouldAutorotateToInterfaceOrientation is not fired. How can i solve the problem?
Its fine to have multiple UIWindows in one app, but the caveat here is that Apple's code seem to check through every UIWindow you have and see if the topmost view controller allows for a certain rotation. If any of those windows allow a rotation your status bar will rotate regardless of whether the UIWindow is frontmost or visible.
In my own app I hide the UIWindow I'm not using, and added a isHidden check in the relevant UIViewControllers to not allow rotation if the window is currently hidden.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With