首页 > 解决方案 > What is this strange white space at the top of my UIViewController when using the Search Controller on my device?

问题描述

Strange Status Bar Behavior on iPhone 7

Left side displays my app in the iPhone 7 simulator. Right side is the app as displayed in my device. When tapping in the search bar, the navbar sildes up but then slides back down as showing in the image with the "What is this?" text.

The code for my search controller is as follows and it is being called in viewDidLoad.

//MARK: - Search Controller
func configureSearchController() {
    searchController.dimsBackgroundDuringPresentation = false
    definesPresentationContext = true
    // to receive updates
    searchController.searchResultsUpdater = self
    // Set up searchbar of search controller
    searchController.searchBar.scopeButtonTitles = ["All", "Something", "Something"]
    searchController.searchBar.delegate = self
    // add the searchbar to the tableview
    tableView.tableHeaderView = searchController.searchBar
    // hack to fix ocassional bugs
    searchController.searchBar.sizeToFit()
}

标签: iosswiftuisearchcontrolleruistatusbar

解决方案


推荐阅读