1

I have a TabbarViewController. In one tab, when navigating to a specific ViewController (a details image view), I want to hide the status bar. I have read this link: How to hide a status bar in iOS?

But in my case, it doesn't work, because I don't want to hide the status bar in the whole app, but just in a specific ViewController.

Is there a way to acheive hiding the scrollbar only in a certain tab?

*Edit: The ViewController I want to hide status bar is a PageViewController. Is that the problem?

Community
  • 1
  • 1

2 Answers2

1
    -(void) viewDidAppear:(BOOL)animated{
        [super viewDidAppear:YES];
        if([UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationLandscapeLeft || [UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationLandscapeRight){
        if ([self respondsToSelector:@selector(setNeedsStatusBarAppearanceUpdate)]){
            [self prefersStatusBarHidden];
            [self performSelector:@selector(setNeedsStatusBarAppearanceUpdate)];
            [[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationSlide];
        }
        else{
            // iOS 6
            [[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationSlide];
        }

    }
    else if([UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationPortrait || [UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationPortraitUpsideDown){
        if ([self respondsToSelector:@selector(setNeedsStatusBarAppearanceUpdate)]){
            [[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationSlide];
            [self performSelector:@selector(setNeedsStatusBarAppearanceUpdate)];
        }
        else{
            // iOS 6
            [[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationSlide];
        }
    }
}

-(UIStatusBarStyle)preferredStatusBarStyle{
    return UIStatusBarStyleLightContent;
}
- (BOOL)prefersStatusBarHidden {
    return YES;
}
Pratik Patel
  • 1,393
  • 12
  • 18
0

Try the following code :

- (void) viewWillAppear:(BOOL)animated{
    [UIApplication sharedApplication].statusBarHidden = YES;
}
Jagat Dave
  • 1,643
  • 3
  • 23
  • 30