1

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.

https://i.stack.imgur.com/RkUSF.jpg

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.

Loïc
  • 11,804
  • 1
  • 31
  • 49

4 Answers4

2

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;
}
Shubhank
  • 21,721
  • 8
  • 65
  • 83
1

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!

Natarajan
  • 3,241
  • 3
  • 17
  • 34
  • After this the bar still show up on iPad. Note that I've defined `Status bar initially hidden` to `YES` (as mentioned in my OP) – Loïc Mar 21 '14 at 09:23
1

Just needed to set deployment infos to universal.

Loïc
  • 11,804
  • 1
  • 31
  • 49
0

Click xCode project/your target/General/Deployement Info, then check the "hide during application launch"

samir
  • 4,501
  • 6
  • 49
  • 76