0
votes

When I call

[[UIApplication sharedApplication] setStatusBarHidden:hideStatusBar];

on a iPad running an iPhone app on scaled mode, the status bar doesn't even hide. Instead, a 20 pixel black space gets pushed onto the top of my iPad views; ultimately getting my app rejected by apple even though I don't want anyone using this 'iPhone only' app on an iPad.

If I remove the setStatusBarHidden call, the iPhone obviously doesn't hide the status bar. On the iPad running scaled mode, the black bar doesn't show up anymore.

View controller-based status bar appearance is set to NO.

I have also tried the following:

- (BOOL)prefersStatusBarHidden
{
  return hideStatusBar;
}

and this set before I need to hide the status bar.

hideStatusBar = YES; //changes
[self setNeedsStatusBarAppearanceUpdate];

However, "prefersStatusBarHidden" isn't called. I just need a solution so that the black bar doesn't appear on the iPad scaled mode and the status bar disappears on the actual iPhone.

I'm running this on iOS 8 and 9.

1
And I prefer not to add code to detect that the app is running in compatibility/scaled mode.kevinl

1 Answers

0
votes

I found that, in addition to the code you've got, you have to create the Info Plist BOOL item View Controller Status Bar Appearance (also called UIViewControllerBasedStatusBarAppearance) and set it to YES.

The code that works for me is:

-(BOOL)prefersStatusBarHidden
{
    return YES;
}

- (void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:NO];

    [self setNeedsStatusBarAppearanceUpdate];
...