简体   繁体   中英

Hide status bar in iphone/ipad apps

I'm working on an application for iPhone iPad.

My test iPhone (v4) is on iOS 6. My test iPad is on iOS 7.

I'd like to remove both statuses bar from the whole application.

Here's what I've tried :

In info.plist, I've set Status bar is initially hidden to YES and View controller based status bar to NO

This didn't work.

So I've set View controller based status bar to YES and in my main view controller I've added :

- (BOOL)prefersStatusBarHidden{
    return YES;
}

Though this function never gets called.

In this same controller I've added this to loadview :

    [[UIApplication sharedApplication] setStatusBarHidden:YES];

This worked for the iPhone, but the bar still shows up on iPad.

Thanks for your help.

EDIT :

I also have checked "Hide during application launch" in project settings.

EDIT :

Here are two screenshots of my project settings.

http://imgur.com/a/VXZTk

As you can see I've tried the answers of the question you voted this as a duplicate to.

If I'm not doing it wrong, thanks for voting to re-open this question.

You need to have two things to have the status bar hidden throughout whole app in all iOS versions

  1. In info.plist View controller based status bar set to NO . (For iOS 7)
  2. In your applicationDidFinishLaunching add [[UIApplication sharedApplication] setStatusBarHidden:YES]; or simply [app setStatusBarHidden:YES]

Now you can optionally set Status bar is initially hidden to YES also to hide status bar when app launches.

Also if you dont want status bar to be hidden throughout the app. remove [[UIApplication sharedApplication] setStatusBarHidden:YES]

and override prefersStatusBarHidden in your ViewControllers and return YES or NO

- (BOOL)prefersStatusBarHidden{
    return YES;
}

If you set Status bar is initially hidden to YES , it will work fine.

Anyways Have you tried below methods?

-(void)viewDidLoad
{
    [super viewDidLoad];

    if ([self respondsToSelector:@selector(setNeedsStatusBarAppearanceUpdate)])
    {
        [self prefersStatusBarHidden];

        [self setNeedsStatusBarAppearanceUpdate];
    }
}

-(BOOL)prefersStatusBarHidden
{        
    return YES;
}

- (UIViewController *)childViewControllerForStatusBarHidden
{
    return nil;
}

Thanks!

只需将部署信息设置为通用即可。

单击“ xCode项目/您的目标/常规/部署信息”,然后选中“在应用程序启动期间隐藏”

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM