I wanted to switch the statusBar in my universal iOS v5 application.
But found that others seem to have UIViews (in my case, subViews added to the main view), just return the 20px left from the hidden statusBar if you then rotate the device (I use the simulator)
And my views are fulfilled programmatically.
I tried some of the suggestions found in googling, but none of them worked. ie autosave / mask change, wants FullScreenLayout, setNeedsLayout, in IB 'use full screen.'
Finally, I realized that I set the frame height to 0 and heights height for my views in [[UIScreen mainScreen] applicationFrame] size.height
What I came up with: set the frame height -20, and the height of the frame at [[UIScreen mainScreen] applicationFrame] size.height + 20
In viewDidLoad.
CGRect theDeviceRect= [[UIScreen mainScreen] applicationFrame]; newMap.frame = CGRectMake(0, -20, theDeviceRect.size.width, theDeviceRect.size.height+20);
I also have this in willAnimateRotationToInterfaceOrientation: delegate.
Now when I switch the status bar with:
- (void) toggleStatusBarAction:(id)sender{ BOOL istathidden= [[UIApplication sharedApplication] isStatusBarHidden]; [[UIApplication sharedApplication] setStatusBarHidden:!istathidden withAnimation:UIStatusBarAnimationFade]; }
Everything works as expected. But I wanted to see if this solution is good or a bad way to do it, and if I am missing something ?:
Thank you very much in advance. Mh