UISearchController apply wrong contentInset to its resultController

Originator:sm11963
Number:rdar://29134501 Date Originated:06-Nov-2016
Status:Open Resolved:No
Product:iOS Product Version:10.1
Classification:UIKit Reproducible:Yes
 
Area:
UIKit

Summary:
On iOS10.1, a UITableViewController displayed by UISearchController has the wrong top contentInset 84 instead of 64.
See attached screenshot & demo project.

The same code on iOS 8 and 9 works correctly.
Everything is compiled with Xcode 8.1

Steps to Reproduce:
Create a UISearchController like this (or see the changes to the example project)

        // Create hints controller
        self.hintsController = SPKSearchHintsViewController() // it's a plain UITableViewController
        
        // Create search controller
        self.searchController = UISearchController(searchResultsController: self.hintsController)
        self.searchController.searchResultsUpdater = self.hintsController
        self.searchController.hidesNavigationBarDuringPresentation = false
        self.searchController.dimsBackgroundDuringPresentation = false
        self.definesPresentationContext = true

        // Prepare searchBar
        let searchBar = self.searchController.searchBar
        searchBar.delegate = self
        searchBar.placeholder = NSLocalizedString("search_placeholder", comment: "Search")
        searchBar.keyboardType = .ASCIICapable
        searchBar.tintColor = UIColor.darkGrayColor()
        
        self.navigationItem.titleView = searchBar // add it to navigation bar

Expected Results:
The contentInset of the tableView inside resultController should be 64 (like it would be in previous iOS versions).

Actual Results:
The contentInset.top is 84. See screenshot attached

Version:
iOS 10.1


Can reproduce with sample project at https://developer.apple.com/library/ios/samplecode/TableSearch_UISearchController/Introduction/Intro.html#//apple_ref/doc/uid/TP40014683

Just replace the line:

tableView.tableHeaderView = searchController.searchBar

with these:

navigationItem.titleView = searchController.searchBar
searchController.hidesNavigationBarDuringPresentation = false

Then use the searchBar in the app to see the issue

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!