UISearchController misplaces UISearchBar

2019-08-08 15:31发布

问题:

I am using the UISearchController on a modal page to allow a user to search some data. The page uses a table view controller design and the searchBar is in a tableViewCell.

When the user taps on the searchBar, the UISearchController animates the layout to slide the table header to the top of the page and moves the searchbar. However it does not end up in the right place. It does not move sufficiently up.

Anyone have a suggestion on how to help the UISearchController to position the searchBar correctly?

Before tapping the search bar (looks ok)

After tapping the search bar (search bar in wrong place)