Why Status Bar rotates and view remains portrait
Asked Answered
H

1

10

My rootViewController is a UITabbarController and contains UINavigationControllers.

In order to restrict rotation, since iOS6, on some but not all views, I have subclassed both of the these controllers to respect the shouldAutorotate response of their topmost or visible view.

This all works just perfectly... most of the time.

In one case, starting from a view (UITableviewController) that does not allow rotation.

I push a view that does allow autorotate, rotate to landscape then back to portrait.

Then when I pop the view, all appears well.

But now if I rotate the device, the status bar alone rotates, leaving a blank space at the top and covering a part of the left side of the current view. The current view does not rotate (as it should not). Only the status bar rotates, back and forth. The view remains responsive, receives touches and works as normal, doesn't resize or respond to rotation in any way (as it should not).

This behavior continues until I kill and restart the app. Once it happens I have found no other way to make it stop. On restart all works properly again and will work properly for an indeterminate duration. I can sit there pushing, popping, rotating back and forth to my hearts content with no issues.

I have never been able to recreate this in simulator.

It happens for no apparent reason, I cannot make it happen. I'd say 85% of the time it works properly. I thought I had it fixed many times when it did not occur for days or even weeks. Then, out of the blue it happens again.

I cannot find a post in any forums which describe this behavior, so I am not finding even a place to start to debug. How could the status bar swing from top to side and the view does not resize or rotate or respond in any way. If I knew how to make that happen, I would have a place to start.

Harvard answered 12/8, 2013 at 14:58 Comment(1)
The problem is with the device orientation(FaceUp, faceDown and unknown orientation) which are not able to set in simulator. But, on the device, you can able to get this orientation. Print the device orientation and then, you can try to debug.Carnelian
S
6

I experienced the same problem when adding a subclassed UIWindow (in my case, a status bar overlay).

The solution was to set the rootViewController of this new UIWindow to a subclassed UIViewController that had -(BOOL)shouldAutorotate implemented. This prevented the status bar from rotating when it wasn't supposed to.

Stilliform answered 25/9, 2013 at 23:31 Comment(2)
I am not altering the status bar in any way so I don't believe this applies. I have not yet experienced this issue now that I've updated for iOS7. With any luck, it was some anomaly with iOS6 and I can write off as "fixed".Harvard
I ran into this problem when I use a Lookback library. It adds additional UIWindow to the UIApplication class. I implemented a UIViewController subclass and override shouldAutorotate. works like a charm.Controversy

© 2022 - 2024 — McMap. All rights reserved.