Question

I have a mostly-navigation-bar-driven application. A few cases require the presentation of a modal view, and one of those cases requires the hiding of the status bar. However, even if I hide the status bar before presenting the modal view, the view is offset by 20 pixels.

Even if I set the frame of the modal view to 0,-20,320,480 after the view appears, it cuts off the top of the view.

I also want the user to be able to reveal the status bar (and a toolbar) upon tapping the screen, much the way the video player works. So I set the style to black transparent for this screen, and I would hope that hiding or showing the statusbar would not cause the view to jump up and down.

Was it helpful?

Solution

Seeing from your comment below that you are targeting iPhone OS 2.x, I have a suggestion that might help.

Before presenting your modal view, do something like this:

  [[UIApplication sharedApplication] setStatusBarHidden:YES animated:YES];
  [[self view] setFrame:CGRectMake(0, 0, 320, 480)];

Make sure that your modal view actually is 480px tall - one time I was fooled by the empty 20px space at the bottom. Turned out it was because my view was still 460px tall (to account for the status bar) so the code actually worked, but my view wasn't the right height.

When hiding your modal view, this works:

[[UIApplication sharedApplication] setStatusBarHidden:NO animated:YES];
[[self view] setFrame:CGRectMake(0, 20, 320, 460)];

You might have to twiddle the code a bit if you are using presentModalViewController - I tried this out using -addSubview because I was using a custom animation. But the basic principles should be the same (i.e. changing the parent view's frame).

OTHER TIPS

Have you looked into the wantsFullScreenLayout property on UIViewControllers?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top