Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UISearchController wrong position because of with tableview inset

I'm working on a feature that has custom view above UITableView, it looks like TableView has contentInset. I added SearchController to a TableViewHeader, but when I tap on searchTextView SearchController moves up with animation (about 20px). I want that UISearchBar will be at the top of ViewController like in "Constacts"

This screenshot shows how it's now:

enter image description here

this one is how I want:

enter image description here

What should i do? I need contentInset after searching (user tapped on cancel), but during the searching I do not need it.

I want to provide app example, that demonstrates all this stuff -> enter link description here

like image 571
Nosov Pavel Avatar asked Jun 08 '17 13:06

Nosov Pavel


2 Answers

If you are using storyboards You should click on the view controller or TableView Controller which you have set up for your tableview and go to its attribute inspector and look under ViewController section and check the Extend Edges section to be under Top Bars.

                      **OR**

Check both Under Top Bars and Under Opaque Bars and leave Under Bottom Bars unchecked.

Do this :

option 1

OR DO this :

option2

like image 62
Samarth Kejriwal Avatar answered Oct 19 '22 18:10

Samarth Kejriwal


Try playing with Adjust Scroll View Insets, Under Top Bars, and Under Bottom Bars in the interface builder. I had the same issue with a collectionView and toggling them off worked for me. You example project works for me but when I toggle between those settings it breaks.

enter image description here

enter image description here

like image 5
Harry Singh Avatar answered Oct 19 '22 20:10

Harry Singh