Swift: fixed searchBar into tableView header

2019-08-16 18:54发布

问题:

I have a tableView with a searchBar inside the table header.

Everything is working well except when I scroll down the rows, the search bar disappear.

How can I make it fixed?

回答1:

There is no a way to maintain the header of a tableView fixed, but an useful approach when you need a unique header, could be to use UIViewController instead of UITableViewController, and set the header (UIView that contains searchBar) above the tableView.