Reputation: 256
This is a follow up on a previous unsolved post. I have a navcontroller, a tableview controller and a searchbar in the tableview. All this is built in storyboard. I then build another viewcontroller programmatically when a cell is selected. I do not want the navigation bar to appear in this last view so, in viewWillDisappear I call
[self.navigationController setNavigationBarHidden:YES animated:animated];
This works just fine IF I select a cell in the main tableView. However, if the cell is selected after narrowing the data from a search in searchbar, then, the navigationbar will appear in the subsequent view although the call to setNavigationBarHidden is made in viewWillDisappear.
I tried repeating this call in viewDidDisappear and, now, the navigation bar disappears from the subsequent view although it is briefly displayed.
I would like to know what happens between the calls to viewWilldisappear and viewDiddisappear that apparently resets the NavigationBarHidden property?
Upvotes: 2
Views: 1146
Reputation: 256
This is what I found: The NavigationBarHidden property is apparently reset because when the searchbar leaves the view, it will send the navigationbar again on the view. I am not sure I understand exactly what is happening, but this line of code in my viewWillDisappear solves the problem:
self.searchDisplayController.active=NO;
followed by:
[self.navigationController setNavigationBarHidden:YES animated:animated];
Of course, I would love to hear from someone who really understands what happens here.
Upvotes: 1