Mattias
Mattias

Reputation: 1131

After performing a push segue, when giving searchbar focus the navigationbar hides

I have two UITableViewControllers, displaying events and objects. Both of them within the same navigationcontroller. Both of them contain Search Display Controllers.

When tapping an object, a push segue is performed to display the events view filtered by the object. After this segue, when tapping the search bar in the EventsViewController, the navigation bar slides up and hides. When the searchbar loses focus, the navigation bar comes back down.

I realize the push segue automatically creates a new navigation bar. But how do I make sure the searchbar doesn't automatically hide the navbar? It stays under the navigationbar as wished for until the push segue is performed.

I can post code if you want, but I doubt that would help in this case. Let me know.

Upvotes: 1

Views: 396

Answers (1)

Mattias
Mattias

Reputation: 1131

I thought I had googled enough, but I just found the answer.

  1. Create a UISearchDisplayController class.
  2. Set the UISearchDisplayControllers as subclass of the created class.
  3. In the UISearchDisplayController class, add the following method:

    -(void)setActive:(BOOL)visible animated:(BOOL)animated
    {
    
        [super setActive:visible animated:animated];
        [self.searchContentsController.navigationController setNavigationBarHidden:NO animated:NO];
    }
    

Upvotes: 1

Related Questions