嗨,我已经在Navigationbar和
中实现了Searchbar以编程方式隐藏导航栏,但该空间并未删除 请帮助我如何删除搜索栏隐藏空间的空间
let search = UISearchController(searchResultsController: nil)
search.searchResultsUpdater = self
search.obscuresBackgroundDuringPresentation = false
search.hidesNavigationBarDuringPresentation = false;
search.searchBar.placeholder = "search..."
self.definesPresentationContext = true
self.navigationItem.searchController = search
用于隐藏SearchBar
search.searchBar.isHidden = false
答案 0 :(得分:1)
隐藏它是不够的,因为它仍然是navigationItem
searchController
,因此您需要将其设置为nil
self.navigationItem.searchController = nil
,然后根据需要还原它,就这么简单。