This is how I setup my UISearchController
(I am using a new controller BackupSearchResultsVC
to show the search result)
class BackupViewViewController: UIViewController {
private lazy var searchController: UISearchController = {
let backupSearchResultsVC = BackupSearchResultsVC.instanceFromNib()
backupSearchResultsVC.postInit(nsBackup)
let searchController = UISearchController(searchResultsController: backupSearchResultsVC)
searchController.searchResultsUpdater = self
searchController.obscuresBackgroundDuringPresentation = true
searchController.searchBar.placeholder = "search_notes".localized
searchController.searchBar.delegate = self
return searchController
}()
override func viewDidLoad() {
super.viewDidLoad()
/** Specify that this view controller determines how the search controller is presented.
The search controller should be presented modally and match the physical size of this view controller.
*/
definesPresentationContext = true
navigationItem.searchController = searchController
}
This is the UI before search begins.
Once the search begins (The search bar will move upward to block the title bar when the search text field is in focus), there is a wide gap between the search result (red background) and the search text bar.
Is there any way to avoid the gap, yet able to use a new controller to show the result?
Thanks.