gpt4 book ai didi

ios - 搜索栏和导航栏之间的空白 - Swift

转载 作者:可可西里 更新时间:2023-11-01 00:58:21 24 4
gpt4 key购买 nike

我有一个简单的 tableViewController、一个带范围的 searchBar 和一个 navigationBar

当我点击我的 searchBar 时,我会看到我的示波器和所有作品。然后我单击一行并转到我的 DetailPage 并且搜索栏没有隐藏(我不知道为什么)。

所以我单击取消,然后返回到我的tableView。当我返回到我的 tableView 时,我的 SearchBar 和我的 NavigationBar 之间有一个空白区域。

Blank space

这是我的代码:

      self.resultSearchController = ({
let controller = UISearchController(searchResultsController: nil)
controller.searchResultsUpdater = self
controller.hidesNavigationBarDuringPresentation = true
controller.dimsBackgroundDuringPresentation = false
controller.searchBar.sizeToFit()
controller.searchBar.scopeButtonTitles = ["Title", "Author", "Location", "Price", "User"]
self.tableView.tableHeaderView = controller.searchBar
return controller
})()

func updateSearchResults(for searchController: UISearchController)
{
let scopes = resultSearchController.searchBar.scopeButtonTitles
let currentScope = scopes![resultSearchController.searchBar.selectedScopeButtonIndex] as String
filterContentForSearchText(searchText: searchController.searchBar.text!, scope: currentScope)
}

最佳答案

尝试添加

  self.automaticallyAdjustsScrollViewInsets = false;

self.extendedLayoutIncludesOpaqueBars = true

viewDidload 中。

关于ios - 搜索栏和导航栏之间的空白 - Swift,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39718958/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com