Tometoyou
Tometoyou

Reputation: 8376

How to stop search bar from hiding on scroll

I have a UINavigationController that has a UISearchController assigned to the navigationItem's searchController. Inside the view I have a UICollectionView. The search bar displays in the navigation bar, but when I scroll, the navigation bar automatically hides. Can I stop this from happening?

let searchController = UISearchController(searchResultsController: recentSearchesViewController)
searchController.searchResultsUpdater = recentSearchesViewController
searchController.dimsBackgroundDuringPresentation = true
definesPresentationContext = true
navigationItem.searchController = searchController

Upvotes: 2

Views: 1392

Answers (1)

Vini App
Vini App

Reputation: 7485

You have to set :

navigationItem.hidesSearchBarWhenScrolling = false

Upvotes: 1

Related Questions