本文介绍了无法在单个UIViewController中隐藏状态栏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在单视图控制器中隐藏状态栏但我的代码无效。
我正在使用以下代码

I want to hide staus bar in single view controller but my code is not working.I'm using the below code

-(BOOL)prefersStatusBarHidden
{
    return YES;
}

&

-(void)viewWillApper:(BOOL)animated{
[[UIApplication sharedApplication] setStatusBarHidden:YES];
}
-(void)viewWillDisappear:(BOOL)animated{
[[UIApplication sharedApplication] setStatusBarHidden:NO];
}


推荐答案

您应该将此值添加到plist:查看基于控制器的状态栏外观并将其设置为NO。

You should add this value to plist: "View controller-based status bar appearance" and set it to "NO".

in

application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions write

 [[UIApplication sharedApplication] setStatusBarHidden:YES];

在viewdidload中添加以下行

Add following line in viewdidload

[[UIApplication sharedApplication] setStatusBarHidden:YES
                                        withAnimation:UIStatusBarAnimationFade];

并添加新方法

 - (BOOL)prefersStatusBarHidden {
          return YES;
  }

这篇关于无法在单个UIViewController中隐藏状态栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-26 17:37