// Why does the tableView containing the searchResults array, after turning to the landscape and back to the portrait, push the top of the View table down, thereby separating the searchBar from the top of the tableView. This happens repeatedly after each turn to the landscape and back. This happens only after the start of the search. This does not happen during rotation if the searchController is not active.
class InitialViewController: UIViewController, UITableViewDataSource, UITableViewDelegate, UISearchResultsUpdating {
@IBOutlet weak var tableView: UITableView!
let searchController = UISearchController(searchResultsController: nil)
let b = searchController.searchBar
b.sizeToFit()
b.scopeButtonTitles = ["Drugs", "Tumor", "Target"]
tableView.tableHeaderView = searchController.searchBar
definesPresentationContext = true
searchController.searchResultsUpdater = self
searchController.dimsBackgroundDuringPresentation = false
source
share