gpt4 book ai didi

iOS8 UISearchController 掩盖了 UITableView

转载 作者:搜寻专家 更新时间:2023-10-31 23:03:24 25 4
gpt4 key购买 nike

我已经为我的 tableview 实现了一个 1UISearchController1,带有范围和一切。但是,当最初加载 View 时它无法正确显示。

根据我的行为,我会看到四种不同的东西。

这是我在 View 首次出现时所看到的。我不希望出现范围栏:

现在,如果我点击搜索栏,我会看到:

接下来,如果我再次单击“取消”按钮,我会在表格 View 中看到:

最后,如果我再次点击搜索栏,我会看到第一次点击搜索栏时的预期结果:

如果我再取消一次,现在搜索栏会正确显示在表格 View 中:

这是我的 TableViewController 的相关部分。

class BaseWineTableViewController: UITableViewController, UITableViewDelegate, UINavigationControllerDelegate, UITableViewDataSource, UISearchResultsUpdating, UISearchBarDelegate, UISearchControllerDelegate {

var resultSearchController = UISearchController()

func ConfigureSearchController() {
self.resultSearchController = UISearchController(searchResultsController: nil)
self.resultSearchController.searchResultsUpdater = self
self.resultSearchController.searchBar.delegate = self
self.resultSearchController.delegate = self

self.resultSearchController.searchBar.showsCancelButton = true
self.resultSearchController.searchBar.autocapitalizationType = .None
self.resultSearchController.searchBar.showsScopeBar = true
self.resultSearchController.searchBar.scopeButtonTitles = ["All", CELLAR_STATUSES.Cellared, CELLAR_STATUSES.Wishlist, CELLAR_STATUSES.Finished]

self.resultSearchController.definesPresentationContext = true
self.resultSearchController.dimsBackgroundDuringPresentation = false
self.tableView.tableHeaderView = resultSearchController.searchBar
}

override func viewDidLoad() {
super.viewDidLoad()
ConfigureSearchController()
}

最佳答案

我想通了。当我删除此行时:

self.resultSearchController.searchBar.showsScopeBar = true

但是留在定义范围标题的行中,它修复了它。

关于iOS8 UISearchController 掩盖了 UITableView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30552492/

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