0

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?

milo526
  • 5,012
  • 5
  • 41
  • 60
Andrea Miotto
  • 7,084
  • 8
  • 45
  • 70
  • Is your search bar in tableview section header. If yes then how many sections do you have in tableview. IF 1 then set the style of your tableview to UITableViewStylePlain and it should stay fixed. – Kapil G Jul 17 '17 at 15:08
  • yes, and yes, and is already plain – Andrea Miotto Jul 17 '17 at 15:18
  • Use delegate method viewForHeaderInSection. Create your custom view add things in this view then return this view – Amit Kumar Jul 17 '17 at 16:04

1 Answers1

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.

Nemanja
  • 194
  • 10