views:

612

answers:

1

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.

A: 

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.

Jasarien
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
Simply resize the view? Set it's frame to (0,20,320,460)?
Jasarien
That worked! Still not exactly sure why I have to set that manually...but thanks!
Greg Maletic
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