gpt4 book ai didi

ios - UITableViewController 隐藏导航栏[搜索栏]

转载 作者:可可西里 更新时间:2023-11-01 00:51:02 26 4
gpt4 key购买 nike

我已将搜索栏添加到导航栏标题 View ,当我开始搜索时,UITableViewController 隐藏了导航栏,如何在导航栏下方获取 UITableViewController。

Before Searching

Before Searching

After Typing

After Typing

Code

        let resultController = mainStoryboard.instantiateViewControllerWithIdentifier("SearchTableViewController") as! UITableViewController

self.searchController = UISearchController(searchResultsController: resultController)
// self.searchController.searchResultsUpdater = self
// self.searchController.delegate = self
// self.searchController.searchBar.delegate = self
self.searchController.searchBar.tintColor = UIColor.whiteColor()
self.searchController.searchBar.placeholder = "Search Outlets"
self.searchController.dimsBackgroundDuringPresentation = false
self.searchController.hidesNavigationBarDuringPresentation = false

最佳答案

据我所知,您的 View Controller 没有设置 definesPresentationContext 属性。如果你不设置这个,奇怪的事情一定会发生。尝试像这样更新您的代码:

let resultController = mainStoryboard.instantiateViewControllerWithIdentifier("SearchTableViewController") as! UITableViewController

self.searchController = UISearchController(searchResultsController: resultController)
//self.searchController.searchResultsUpdater = self
//self.searchController.delegate = self
//self.searchController.searchBar.delegate = self
self.searchController.searchBar.tintColor = UIColor.whiteColor()
self.searchController.searchBar.placeholder = "Search Outlets"
self.searchController.dimsBackgroundDuringPresentation = false
self.searchController.hidesNavigationBarDuringPresentation = false

self.definesPresentationContext = true

最后一行是我添加的行。当我在我自己的应用程序中对此进行测试时,未指定此行会导致您看到的行为。

关于ios - UITableViewController 隐藏导航栏[搜索栏],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38955822/

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