iPhone - displaying NavigationBar on a fullscreen modalView makes it go down with transparent space on top

若如初见. 提交于 2019-12-24 05:49:34

问题


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:


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.



来源:https://stackoverflow.com/questions/5362322/iphone-displaying-navigationbar-on-a-fullscreen-modalview-makes-it-go-down-wit

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!