With the status bar initially visible, I add a subview and hide the status bar:
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationSlide];
[myController.view addSubview:anotherController.view];
In this view there is a button to toggle the status bar visibility, but when I set statusBarHidden
to NO
again, the view controller's view doesn't auto resize to take into account the status bar, and as a result the view is pushed down and cut off by 20px. I've set all the appropriate resizing masks to the view and also tried auto-layout, but neither seem to work. I'd like my view to resize automatically when showing/hiding status bar without manually setting its frame.
Update
Instead of adding it the root view controller's view, I've pushed it onto the stack of my navigation controller, and hidden the status bar and navigation bar. I then give the user the option to toggle only the status bar. However the problem still remains and the view is pushed and cut off by 20px when the status bar reappears.
But when I rotate the device, everything is in its place - only if I rotate the device after the status bar has been hidden.