Make iPhone status bar disappear when displaying a modal view?

You'll be wanting the - (void)setStatusBarHidden:(BOOL)hidden animated:(BOOL)animated on the UIApplication class.

Up vote 3 down vote favorite share g+ share fb share tw.

I want to display a modal view, and want it to cover the iPhone's status bar. I tried setting the modal view controller's wantsFullScreenLayout property to YES; I also set its parent's property to YES as well. This doesn't work, presumably because the modal view displays below the main window's content, which includes the status bar.

My second approach dropped the whole "wantsFullScreenLayout" technique in favor of hiding the status bar just before the modal view is displayed, then turning it back on after the modal view is dismissed. This works until the very end...the modal view's parent view is laid out incorrectly (its navigation bar is partially hidden behind the status bar. ) Calling -view setNeedsLayout does nothing.

How should I approach this problem? Thanks. Iphone modal fullscreen statusbar link|improve this question asked Feb 2 '10 at 22:54Greg Maletic7961827 56% accept rate.

You'll be wanting the - (void)setStatusBarHidden:(BOOL)hidden animated:(BOOL)animated on the UIApplication class. Something like this: UIApplication sharedApplication setStatusBarHidden:YES animated:YES; That should hide the status bar with a nice fade animation.

I already tried that (see 2nd approach above). I don't have a problem making the status bar hide and re-appear; the problem is having the view layout properly once I make it re-appear. Thanks.

– Greg Maletic Feb 3 '10 at 0:37 Simply resize the view? Set it's frame to (0,20,320,460)? – Jasarien Feb 3 '10 at 9:51 That worked!

Still not exactly sure why I have to set that manually...but thanks! – Greg Maletic Feb 5 '10 at 1:09 I could be wrong - but I think set needs layout will only resize/reposition subviews, not the view itself. It might work if you call setNeedsDisplay, but I can't promise anything.

– Jasarien Feb 5 '10 at 11:34 WHERE do you resize the view and reshow the status bar? I tried doing both in viewWillAppear to no luck. The status bar will come back but with an incorrect layout.

– AndrewS Nov 16 '10 at 18:33.

Joining the discusion late, but I think I can save others some trouble. I have a VC several pushes into a NavController (let's call that VC the PARENT). Now I want to display a modal screen (the CHILD) with the nav bar AND status bar hidden.

After much experimentation, I know this works... 1) Because I present the CHILD VC by calling presentModalViewController:(UIViewController *)modalViewController animated:(BOOL)animated in the PARENT, the nav bar is not involved anymore (no need to hide it). 2) The view in the CHILD VC nib is sized to 320x480. 3) The CHILD VC sets self.

WantsFullScreenLayout = YES; in viewDidLoad 4) just before presenting the CHILD, hide the status bar with UIApplication sharedApplication setStatusBarHidden:YES withAnimation:YES; 5) dismiss the CHILD VC using a delegate protocol methods in the PARENT, and call UIApplication sharedApplication setStatusBarHidden:NO withAnimation:YES; before dismissModalViewControllerAnimated:YES to make sure the nav bar is drawn in the correct location Hope this helps.

1 for 4). I solved it without the other steps though and displayed the status bar again in -viewWillDisappear: in the modal view. – Kristofer Sommestad Oct 5 '11 at 18:51.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions