I have a UICollectionView
in red.
When I start to perform searching by entering the 1st character, I expect the result view controller (in yellow) will cover the entire UICollectionView
.
It should not cover the top navigation bar.
But seems like this is not the case. May I know why?
My code is pretty straightforward.
import UIKit
class ViewController: UIViewController {
lazy var searchController = UISearchController(searchResultsController: ResultVC())
func ResultVC() -> UIViewController {
let resultVC = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "ResultVC") as UIViewController
return resultVC
}
override func viewDidLoad() {
super.viewDidLoad()
searchController.searchResultsUpdater = self
searchController.obscuresBackgroundDuringPresentation = true
searchController.searchBar.placeholder = "Search"
searchController.searchBar.delegate = self
navigationItem.searchController = searchController
}
}
extension ViewController: UISearchBarDelegate {
}
extension ViewController: UISearchResultsUpdating {
func updateSearchResults(for searchController: UISearchController) {
}
}