Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

setNavigationBarHidden:YES doesn't work with the searchDisplayController

I'm using the following code to hide my navigationBar in the detailViewController(my second view), and it works perfectly fine when I tap any of my object from the MasterViewController(my first view).

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

However, when I filter the table list in the masterViewController using searchDisplayController and tap any object from the result, the navigationBar in the detailView doesn't get hidden...

Do I have to do any extra work to hide the navigationBar if I use the searchDisplayController?

for Debug, I set the break point on the line of setNavigationBarHidden:YES, and even if I go to the detailViewController via search result, the application hits the line..

like image 543
sora Avatar asked Jan 21 '12 03:01

sora


1 Answers

you shuold put [self.navigationController setNavigationBarHidden:YES]; in viewWillLayoutSubviews function.like this:

- (void) viewWillLayoutSubviews
{
    [super viewWillLayoutSubviews];
    [self.navigationController setNavigationBarHidden:YES];
}

it works.

like image 122
jt6562 Avatar answered Nov 11 '22 17:11

jt6562