我有这样的情况:
控制器A和B:
override func viewDidLoad() {
super.viewDidLoad()
setupSearchController()
}
private func setupSearchController(){
let searchResultController = SearchResultsTableViewController()
searchResultController.delegate = self
searchController = UISearchController.init(searchResultsController: searchResultController)
navigationItem.searchController = searchController
navigationItem.hidesSearchBarWhenScrolling = false
searchController.searchResultsUpdater = self
searchController.searchBar.delegate = self
searchController.dimsBackgroundDuringPresentation = true
searchController.searchBar.enablesReturnKeyAutomatically = false
definesPresentationContext = true
}
控制器A是带有搜索栏的主屏幕控制器。单击搜索按钮后,控制器A按下显示搜索短语结果的控制器B.当我尝试开始向后滑动并取消时,会出现GIF的情况。控制器B中的搜索栏完全删除,即使滚动条也无法显示。
我找到的唯一解决方法是每次在viewDidAppear中创建SearchController并设置导航项。这解决了gif中显示的问题,但是有一点闪光/可见调整大小反而令人讨厌。还有其他解决方法吗?