Pregunta

I have a signup form that pops up when a button is tapped. My aim is to hide the status bar when this modal is popped up.

Here is my code:

- (IBAction)tappedJoinButton:(id)sender {

    if (![PFUser currentUser]) {

        PFSignUpViewController *signUpViewController = [[PFSignUpViewController alloc] init];
        [signUpViewController setDelegate:self]; // Set ourselves as the delegate

        // Present the sign up view controller
        [self presentViewController:signUpViewController animated:YES completion:NULL];
    }
}

I have set View controller-based status bar appearance to yes in my plist file. Now I'd like to choose where I hide the status bar. In this situation I'd like to hide it in the signUpViewController that pops up.

I haven't seen any answers on here showing how to hide it in a pushed view controller.

How do I achieve this?

Kind regards

¿Fue útil?

Solución

If you want to hide status bar for only one ViewController the do this:

- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    [[UIApplication sharedApplication] setStatusBarHidden:YES];

}


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

For your case it will be in PFSignUpViewController.

Hope this helps .. :)

Otros consejos

Try this code

in viewDidload of PFSignUpViewController

 if ([self respondsToSelector:@selector(setNeedsStatusBarAppearanceUpdate)]) {
    // iOS 7
    [self performSelector:@selector(setNeedsStatusBarAppearanceUpdate)];
} else {
    // iOS 6
    [[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationSlide];
}

paste this function in controller

- (BOOL)prefersStatusBarHidden {
return YES;
}

you lust like ....

if ([UIApplication sharedApplication].statusBarHidden != hideStatusBar)
{

    [[UIApplication sharedApplication] setStatusBarHidden:hideStatusBar withAnimation:UIStatusBarAnimationSlide];
}

Write this in your viewWillAppear...

       [[UIApplication sharedApplication] setStatusBarHidden:YES];

Or try This method ....

       -(void)navigationController:(UINavigationController *)
   navigationController willShowViewController:(UIViewController *)
   viewController animated:(BOOL)animated

       {
          [[UIApplication sharedApplication] setStatusBarHidden:YES];

        }

Add this "View controller-based status bar" appearance in the plist and set NO

  [[UIApplication sharedApplication] setStatusBarHidden:YES];  
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top