Search code examples
uinavigationbaruisearchdisplaycontroller

Hiding UINavigationBar


I have stocked in a confusing situation. I'm using a Navigation Controller and UIPageViewController.

first we have a view contains a TableView with searchDisplayController. this table view shows a list of story. you can select a cell and go to another view(page based view) and read the story. so in the second view I have hidden the navigation bar. because the reader wants to curl the pages.

here every thing works well until I search for a word in searchBar (first view) and after selecting the cell, and going to the second view the navigation bar won't hide!

both view has inherited from UIViewController.

and in the second view, I did this:

- (void)viewWillAppear:(BOOL)animated
{
  [super viewWillAppear:animated];

  [self.navigationController setNavigationBarHidden:YES animated:animated];
    if (self.navigationController.navigationBarHidden) {
        NSLog(@"navigation bar is hidden");
    }

}

even I explicitly hide the navigation Bar, when it reaches the If statement, it appears the navigation bar is not hidden.

what am I doing wrong?


Solution

  • i found the answer here:

    https://stackoverflow.com/a/6337037/1348121

    UISearch display controller has a built in Navigation Bar and we must hack it in some way to disable it.