Setting the UITableView contentInset is also the header view of the insert section

I am changing the contents of tableviewsInset so that when the user scrolls to the top of the table, the tableview is an insert to display the UISearchBar hidden above the table view.

Everything works fine except for section headers. when scrolling down, the upper border of the HeaderView section is inserted at the same distance from the top of the screen as my table insert, here it is in the starting position:

Header view in correct position

In the above image, the sequencer view is in its correct position, and the insertion of the lookup table has been displayed in the search field.

enter image description here

You can see in this second screenshot where the upper border of the headerview is set lower due to the 43-pixel insertion of the table, where it should adhere to the top of the screen, hiding the "related" cell and bouncing back when released,

I think I need to somehow shift the insert, I'm just not sure how ..

+6
source share
1 answer

I assume that you want this search box, as in the Mail application; Search field at the very top of the list, which is not displayed by default?

The solution is not to use contentInset , but instead:

  • Define a UISearchBar as tableHeaderView tables.
  • Also add the UISearchDisplayController to the table view controller.
  • By default, set contentOffset 44 points down to hide the search bar.

Apple has a good sample application as a starting point here: http://developer.apple.com/library/ios/#samplecode/TableSearch/Introduction/Intro.html

+6
source

Source: https://habr.com/ru/post/888040/


All Articles