views:

378

answers:

2

I have a UISearchDisplayController setup with a UITableViewController which is nested inside a UINavigationController. When a selection of a cell is made, UITableView's didSelectRowAtIndexPath method is triggered, which pushes a new view to the parent navigation controller. This new view should have the navigation bar hidden on entry.

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

I use this line in the didSelectRowAtIndexPath method to hide the navigation bar. This works fine when a row is selected not using the search controller, but is overridden when selecting a search result. It seems the UISearchDisplayController takes it in its right to un-hide the navigationBar sometime after the row is selected.

If I move the setNavigationBarHidden call into the target view's viewWillAppear method, results are similar. I can make it work by placing the hide call in viewDidAppear, but this makes for a very awkward transition effect which feels jumpy and out of place. I would like to make the navigationBar already hidden before the new view slides on to the screen.

Does anyone know where the unhiding of the navigationBar is occurring, and/or any way I can override this behaviour?

A: 

Hi, I'm having a similar problem. In my case the navigationBar should be visible after didSelectRowAtIndexPath is called, the problem is the navigationBar overlaps my tableview (like when the navigationBar is set to transparent, but it's set opaque!). This strange behavior occur only when the new viewcontroller is pushed using the search controller. Have you solved?

Sorry, I should respond as comment, not as answer. My fault

ggould75
A: 

Bumped into the same problem, managed to get it working smoothly with this ugly hack:

- (void) viewWillDisappear: (BOOL) animated 
{
    if (searchController_.active)       
    {
        self.navigationController.navigationBar.barStyle = UIBarStyleBlackTranslucent;
        self.navigationController.navigationBar.tintColor = nil;        
    }

    [super viewWillDisappear: animated];
}


- (void) viewWillAppear: (BOOL) animated 
{       
    if (searchController_.active)       
    {
        self.navigationController.navigationBar.barStyle = UIBarStyleDefault;
    }

    [super viewWillAppear: animated];
}
leonelmartins