我的代码:
let searchController = UISearchController(searchResultsController: nil)
override func viewDidLoad() {
super.viewDidLoad()
// MARK: - Search
searchController.searchBar.delegate = self
navigationItem.titleView = searchController.searchBar
}
func searchBarTextDidBeginEditing(searchBar: UISearchBar) {
presentViewController(searchController, animated: true, completion: nil)
}
答案 0 :(得分:1)
试试这个
self.searchController.hidesNavigationBarDuringPresentation = NO
self.definesPresentationContext = NO
或使用此
func willPresentSearchController(searchController: UISearchController) {
self.navigationController.navigationBar.translucent = true
}
func willDismissSearchController(searchController: UISearchController) {
self.navigationController.navigationBar.translucent = false
}
获取其他帮助,请参阅此link
答案 1 :(得分:0)
尝试设置Viewcontroller的此属性
self.definesPresentationContext = NO