不添加 UISearchController
Doesn't add UISearchController
我正在尝试以编程方式将 UISearchController 添加到 UICollectionViewController。
但是没用。怎么了?
不会出现在模拟器上
class PicturesCollectionViewController: UICollectionViewController {
override func viewDidLoad() {
super.viewDidLoad()
setupSearchBar()
}
private func setupSearchBar() {
let searchController = UISearchController(searchResultsController: nil)
navigationItem.searchController = searchController
}
// ... numberOfItemsInSection && cellForItemAt indexPath
}
事实是我在模拟器上测试,没有考虑
navigationItem.hidesSearchBarWhenScrolling = false
我正在尝试以编程方式将 UISearchController 添加到 UICollectionViewController。
但是没用。怎么了? 不会出现在模拟器上
class PicturesCollectionViewController: UICollectionViewController {
override func viewDidLoad() {
super.viewDidLoad()
setupSearchBar()
}
private func setupSearchBar() {
let searchController = UISearchController(searchResultsController: nil)
navigationItem.searchController = searchController
}
// ... numberOfItemsInSection && cellForItemAt indexPath
}
事实是我在模拟器上测试,没有考虑
navigationItem.hidesSearchBarWhenScrolling = false