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.
source to share
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];
source to share
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).
source to share
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];
}
source to share
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.
source to share