I wanted to toggle the statusBar in my iOS v5 universal app.
But found as it seems others have that UIViews (in my case subViews added to the main view) only reclaim the 20px left by the hidden statusBar if you then rotate the device (I am using the simulator )
And my views are done programmatically.
I tried some of the suggestions found by googling but none seemed to work. i.e changing autoresizing/mask, wantsFullScreenLayout, setNeedsLayout, in IB 'use full screen.'
I finally realised that I was setting my views frame height to 0 and it's bounds height to the [[UIScreen mainScreen] applicationFrame] size.height
What I came up with is: setting the views frame height to -20 and it's bounds height to the [[UIScreen mainScreen] applicationFrame] size.height+20
In the viewDidLoad.
CGRect theDeviceRect= [[UIScreen mainScreen] applicationFrame];
newMap.frame = CGRectMake(0, -20, theDeviceRect.size.width, theDeviceRect.size.height+20);
I also have this in the willAnimateRotationToInterfaceOrientation: delegate.
Now when I toggle the status bar with:
- (void) toggleStatusBarAction:(id)sender{
BOOL istathidden= [[UIApplication sharedApplication] isStatusBarHidden];
[[UIApplication sharedApplication] setStatusBarHidden:!istathidden withAnimation:UIStatusBarAnimationFade];
}
All works as expected. But I wanted to see if my solution is good or bad way of going about this and if I am missing anything?:
Many thanks in advance. MH