Make iPhone status bar disappear when displaying modal view?

I want to display a modal view and want it to cover the status bar of the iPhone.

I tried to establish that the modal view controller requires the FullScreenLayout property for YES; I also set its parent property to YES. This does not work, apparently because the modal view is displayed below the contents of the main window, which includes the status bar.

My second approach dumped the whole “wants FullScreenLayout” technique in favor of hiding the status bar just before the modal view was displayed, and then turned on again after the modal view was rejected. This works until the very end ... the parent view of the modal view is not laid out correctly (its navigation bar is partially hidden behind the status bar). Calling - [view setNeedsLayout] does nothing.

How do I approach this problem?

Thanks.

+6
iphone modal-dialog fullscreen statusbar
source share
2 answers

You will need - (void)setStatusBarHidden:(BOOL)hidden animated:(BOOL)animated in the UIApplication class.

Something like that:

 [[UIApplication sharedApplication] setStatusBarHidden:YES animated:YES]; 

This should hide the status bar with a nice fade animation.

+2
source share

Entering the discussion late, but I think I can save others from trouble.

I have a VC a few taps in the NavController (let me call VC PARENT). Now I want to display a modal screen (BABY) with a hidden navigation bar and status. After much experimentation, I know this works ...

1) Since I represent CHILD VC by calling presentModalViewController:(UIViewController *)modalViewController animated:(BOOL)animated in PARENT, the navigation bar is no longer involved (no need to hide it).

2) View in the strap CHILD VC size 320x480.

3) CHILD VC sets self.wantsFullScreenLayout = YES; in viewDidLoad

4) before representing the CHILD, hide the status bar using [[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:YES];

5) release CHILD VC using the delegate protocol methods in PARENT and call [[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:YES]; before dismissModalViewControllerAnimated:YES] to make sure the navigation bar is displayed in the correct place.

Hope this helps.

+12
source share

All Articles