导航栏Searchbar Space并没有隐藏在Swift 4.2中

问题描述 投票:0回答:1

Navigationbar with SearchBar

enter image description here

我已经在导航栏中实现了搜索栏

以编程方式隐藏导航栏但空间不移除PLease帮助我如何删除搜索栏隐藏空间的空间

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

用于隐藏搜索栏

search.searchBar.isHidden = false
ios swift uinavigationbar uisearchbar
1个回答
1
投票

隐藏它是不够的,因为它仍然是navigationItem searchController,所以你需要将它设置为nil

self.navigationItem.searchController = nil

然后如果你想要恢复它,就像那样简单。

© www.soinside.com 2019 - 2024. All rights reserved.