OGeek|极客世界-中国程序员成长平台

标题: ios - 如何使用objective-C在ios 9中隐藏特定 View Controller 的状态栏 [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-13 13:37
标题: ios - 如何使用objective-C在ios 9中隐藏特定 View Controller 的状态栏

我想隐藏特定 View Controller 的状态栏,而不是全部。 然后我尝试了这个,

[[UIApplication sharedApplication] setStatusBarHidden:YES]; in the `.AppDelegate.m` inside the `didfinishlaunchwithoption`  but it didn't work. and also it is deprecated.

然后我在我的 View Controller 中尝试了

- (BOOL) prefersStatusBarHidden{
    return YES;
}

这也没有用。任何人都可以帮我解决这个问题。thnak 你 我不想在这里使用任何已弃用的方法



Best Answer-推荐答案


转到 info.plist 并添加两个属性(如果不存在)。将“状态栏最初隐藏”设置为“YES”并将“UIViewControllerBasedStatusBarAppearance”设置为“YES”。这将隐藏您应用的状态栏。

-(BOOL)prefersStatusBarHidden
{
    return YES;
}

并在你想要的地方调用这个方法,例如从 viewDidLoad

[self prefersStatusBarHidden];

关于ios - 如何使用objective-C在ios 9中隐藏特定 View Controller 的状态栏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34848618/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://sqlite.in/) Powered by Discuz! X3.4