Ios 在导航栏中打开UISearchController时,整个应用程序将冻结
我正在制作一个包含加密货币列表的应用程序。应该能够在这3个过滤列表(BTC、ETH、USD)中进行搜索。我唯一的问题是搜索栏 只要我按下“放大镜”图标,搜索栏就会出现,但整个应用程序都冻结了。我无法按“取消”,键入栏,关闭它并移动UITableView。我不明白这种行为的原因Ios 在导航栏中打开UISearchController时,整个应用程序将冻结,ios,swift,uisearchcontroller,Ios,Swift,Uisearchcontroller,我正在制作一个包含加密货币列表的应用程序。应该能够在这3个过滤列表(BTC、ETH、USD)中进行搜索。我唯一的问题是搜索栏 只要我按下“放大镜”图标,搜索栏就会出现,但整个应用程序都冻结了。我无法按“取消”,键入栏,关闭它并移动UITableView。我不明白这种行为的原因 var searchController : UISearchController! @IBAction func searchingButton(_ sender: Any) { searchControl
var searchController : UISearchController!
@IBAction func searchingButton(_ sender: Any) {
searchController = UISearchController(searchResultsController: nil)
searchController.delegate = self
searchController.searchBar.delegate = self
searchController.searchBar.placeholder = "All currency pairs"
searchController.hidesNavigationBarDuringPresentation = false
searchController.searchResultsUpdater = self
definesPresentationContext = true
navigationItem.searchController = self.searchController
navigationItem.hidesSearchBarWhenScrolling = false
searchButton.isHidden = true
present(searchController, animated: true, completion: nil)
}
extension ViewController: UISearchControllerDelegate {
func searchBarCancelButtonClicked(_ searchBar: UISearchBar) {
navigationItem.searchController = nil
navigationController?.view.setNeedsLayout()
navigationController?.view.layoutIfNeeded()
self.indexChange(self.segmentedControl!)
}
}
请帮我解决这个问题。如果需要,将提供更多的代码。嗯,这很奇怪,但是清理项目和系统重启有帮助