Self.navigationController.navigationBar.hidden = TRUE; Vs [self.navigationController.navigationBar setHidden: YES];

What is the difference between these two statements. To hide the navigation bar, I use one of these operators to hide the navigation bar in WillAppear view, as shown below:

 -(void)viewWillAppear:(BOOL)animated
{
    self.navigationController.navigationBar.hidden=true;   //works....
}

 -(void)viewWillAppear:(BOOL)animated
{
    [self.navigationController.navigationBar setHidden:YES]; //doesn't work...
}

      

This code works fine with self.navigationController.navigationBar.hidden = true; but when i use [self.navigationController.navigationBar setHidden: YES]; This does not work. Why?

Sorry, I had a mistake. Now corrected, please again.

+3


source to share


6 answers


FWIW, I ran into a situation today in iOS 6 where:

self.navigationController.navigationBar.hidden = YES;

      



turned out to be zero. What is this job:

[self.navigationController setNavigationBarHidden:YES animated:NO];

      

+4


source


The difference is that it hides it while the other shows it :)

YES = TRUE 
NO = FALSE

      

Hides the navigation bar



self.navigationController.navigationBar.hidden=TRUE;
[self.navigationController.navigationBar setHidden:YES]; 

      

Shows the navigation bar

 self.navigationController.navigationBar.hidden=FALSE;
[self.navigationController.navigationBar setHidden:NO]; 

      

+1


source


self.navigationItem.hidesBackButton = NO;

This will only hide the BackButton of the navigation bar.

self.navigationController.navigationBar.hidden = false;

This will hide the navigation bar, including its BackButton.

self.navigationController.navigationBar.hidden = true;

This will enable the navigation bar to be used.

self.navigationItem.hidesBackButton = YES;

This will enable the BackButton of the navigation bar (until the navigation bar is hidden).

+1


source


This code: self.navigationItem.hidesBackButton = YES;

actually hides the return button

which are displayed on the navigation bar. This code:

 self.navigationController.navigationBar.hidden=false;

      

don't actually hide the navbar showing the navbar at the top of the window.

0


source


Maybe your code will work with changing YES to NO

You can use setNavigationBarHidden: animated: works for me.

-(void)viewWillDisappear:(BOOL)animated
{
    [super viewDidDisappear:animated];
    [self.navigationController setNavigationBarHidden:NO animated:YES];
}
-(void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    [self.navigationController setNavigationBarHidden:YES animated:YES];
}

      

0


source


If you want to hide the navbar you have to use this: -

self.navigationController.navigationBarHidden = YES;

      

or

[self.navigationController setNavigationBarHidden:YES];

      

And it works great every time.

And your case should work fine, but as we can all see, this is just some internal iOS inconsistency.

0


source







All Articles