Elias Rahme
Elias Rahme

Reputation: 2227

Keep a UISearchBar fixed in place whenever the tableview is scrolling

I need to keep my UISearchBar fixed in place whenever I scroll down my UITableView, I want it to stay in place fixed and do not disappear all of a sudden. How can i do it?

Upvotes: 1

Views: 2257

Answers (1)

ff10
ff10

Reputation: 3147

I suggest to decouple the search bar from the table view, i.e. start the view of the table view just under a custom view which holds the search bar.

Edit for clarification: Instead of coupling the UISearchBar with the UITableView (i.e.: defining the search bar as the tableview header) create a sole UITableView (w/o search bar) and a sole UISearchbar. You have two views for the same logic instead of one view. Before, you had a UITableView which holds a UISearchbar for its header. Now you have a plain UITableView and a UISearchbar.

It is therefore up to you, where you want to have the search bar. If you prefer to have a search bar on top of the tableview, just define a view above the tableview and add the search bar to this view.

Upvotes: 2

Related Questions