简体   繁体   中英

iOS 11 tableView with searchBar issue

Please help to determine the reason of such behavior (it's hard to describe by words, so I recorded the short video) https://youtu.be/E2ks0liFX4I

In short words: Initially it's able to scroll content beneath navigation bar. If press search field - the search bar looks like detached from table view and goes too high and overlapped by status bar (look at increased space between grey border of search bar and first row in the table). After Cancel button pressed - the search bar jumps down and now can't be hided by scrolling.

I'm using UITableViewController. Search bar initialization in viewDidLoad:

searchController = UISearchController(searchResultsController: nil)
searchController.searchResultsUpdater = self
searchController.dimsBackgroundDuringPresentation = false
tableView.tableHeaderView = searchController.searchBar

And in StoryBoard: tableView settings

Not sure what u want. I guess u want the search bar to hide when scrolling? I set searchbar to the navigationItem, then set the hidesSearchBarWhenScrolling property.

navigationItem.searchController = searchController
navigationItem.hidesSearchBarWhenScrolling = true

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM