iPhone - displaying NavigationBar on a fullscreen

2019-07-30 01:52发布

I have a ModalView called with :

    PreferencesController *nextWindow = [[[PreferencesController alloc] initWithNibName:@"Preferences" bundle:nil] autorelease];
    nextWindow.wantsFullScreenLayout = YES;
    UINavigationController* navController = [[[UINavigationController alloc] initWithRootViewController:nextWindow] autorelease];

    [self presentModalViewController:navController animated:YES];

It is initialised like this :

- (void)viewDidLoad
{
    [super viewDidLoad];
    self.navigationController.navigationBarHidden = YES;
    self.title = @"Options";
}

When I set, on a button click (for test) :

- (IBAction)ClickIt:(id)sender {
    self.navigationController.navigationBarHidden = NO;
}

Then the navigtion bar is displayed, but then the whole view goes down with a transparent space on the Top of the view, with a size of a status bar. The simulated elements in the xibs for the status bar are set to OFF, as for all the other simulated elements.
Due to this space, the bottom content of the view goes out of screen.
I tried to force self.wantsFullScreenLayout = YES after having set navigationBarHidden = NO but that does not change anything.

For information, if I change viewDidLoad like this :

- (void)viewDidLoad
{
    [super viewDidLoad];
    self.navigationController.navigationBarHidden = NO;
    self.title = @"Options";
}

Then the problem is the same without having to click the test button.

What could be the problem ?

1条回答
Lonely孤独者°
2楼-- · 2019-07-30 02:15

As indicated in this question you might need to hide the statusbar before presenting your full screen view controller, for instance directly on application load.

查看更多
登录 后发表回答