Reputation: 21
Is it possible that the tableHeaderView stays on the top even if the tableView has multiple sections?
What I have:
A navigationController who leads to a tableViewController The header of the tableView is a searchbar (I want it to stay at the top) and multiple section. I use swift.
The titles of the sections always stay at the top (replacing each other while scrolling) but I would like that the tableheader always stays at the top and not being replaced by a section title.
1 constraint: I am using a tableViewController and not a View controller (in which I could have a fix uiview and a tableview).
Similarly to what we have when we look in our iPhone contact list
Upvotes: 0
Views: 737
Reputation: 21
I am answering my question, the easy way is to add the search in the navigation bar.
if #available(iOS 11.0, *) {
...
let searchController = UISearchController(searchResultsController: yourResultController) // Search Controller
navigationItem.hidesSearchBarWhenScrolling = false
navigationItem.searchController = searchController
}
This replicate the behavior of the Contact list.
Some other intersting read on how to customize it: http://iosrevisited.blogspot.be/2017/11/add-search-controller-in-navigation-bar-swift.html
Upvotes: 1