iOS 6, initially hidden status bars, and UITabBar clipping

My app has a tab bar as its main view. Its status bar is hidden at app launch, via an Info.plist entry:


When the app finishes launching, the app delegate makes the status bar visible.

    [application setStatusBarHidden:NO withAnimation:UIStatusBarAnimationFade];

Unfortunately, this causes the content of the tab bar's current view to extend under the status bar.

Extending under status bar

And there it stays until the app is rotated.

I tried to fix this by resetting the main window frame as soon as the status bar was made visible:

    self.window.frame = [[UIScreen mainScreen] applicationFrame];

This worked, but only until the app was rotated. If the app was initially in portrait orientation, then rotating to landscape and back to portrait caused the tab bar's view to shift downward 20 pixels -- the status bar height -- so the bottom of the tab bar was clipped.

Clipped tab bar

Happily, a discussion on Stack Overflow triggered a head smack: I was changing the frame too soon. I should have been subclassing UITabBarController, overriding viewDidAppear:, and adjusting the view's frame there:

- (void)viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];
    self.view.frame = [[UIScreen mainScreen] applicationFrame];

Problem solved. Thanks again, Stack Overflow.