12

Is it possible to have the status bar hidden in just one scene in the Storyboard?

For example:

I want it hidden in "ViewController A", but when moving via a segue to "ViewController B" (eg, a Navigation Controller) the status bar will be shown.

I gather you can disable it throughout the app, but how do you do it for just one ViewController?


The suggestion from below does work, however when switching to the Navigation Controller it seems to cause the nav bar to be drawn in the wrong location.

nav bar bug

4

4 回答 4

30

怎么样

- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    [[UIApplication sharedApplication] setStatusBarHidden:YES];

}


- (void)viewWillDisappear:(BOOL)animated{
    [[UIApplication sharedApplication] setStatusBarHidden:NO];
    [super viewWillDisappear:animated];
}
于 2013-06-22T18:48:23.623 回答
17

只需将代码放在 ViewController.m 上(在 iOS7,Xcode 5 中)

- (BOOL) prefersStatusBarHidden { return YES; }

于 2014-04-04T10:08:00.547 回答
0

我的解决方案:在情节提要中,选择您的场景并在属性检查器中设置状态栏:无。

于 2013-07-17T14:15:53.417 回答
0

对于斯威夫特 4:

override var prefersStatusBarHidden: Bool {
    return true
}
于 2018-05-10T15:10:28.150 回答