gpt4 book ai didi

ios - 为什么在 UISearchBar 上打字时 UISearchController 消失了?

转载 作者:可可西里 更新时间:2023-10-31 23:13:22 24 4
gpt4 key购买 nike

func configureSearchController() {
// Initialize and perform a minimum configuration to the search controller.
searchController = UISearchController(searchResultsController: nil)
searchController.searchResultsUpdater = self
searchController.dimsBackgroundDuringPresentation = false
searchController.searchBar.placeholder = "Search"
searchController.searchBar.delegate = self
searchController.searchBar.sizeToFit()

// Add search bar to View.
self.view.addSubview(searchController.searchBar)

searchController.searchBar.translatesAutoresizingMaskIntoConstraints = false

view.bringSubview(toFront: searchController.searchBar)

//add constraints on searchbar
view.addConstraint(NSLayoutConstraint(item: searchController.searchBar, attribute: .trailing, relatedBy: .equal, toItem: view, attribute: .trailing, multiplier: 1, constant: 0))
view.addConstraint(NSLayoutConstraint(item: searchController.searchBar, attribute: .leading, relatedBy: .equal, toItem: view, attribute: .leading, multiplier: 1, constant: 0))

view.addConstraint(NSLayoutConstraint(item: searchController.searchBar, attribute: .top, relatedBy: .equal, toItem: self.topLayoutGuide, attribute: .bottom, multiplier: 1, constant: 0))
view.addConstraint(NSLayoutConstraint(item: searchController.searchBar, attribute: .height, relatedBy: .equal, toItem: nil, attribute: .notAnAttribute,multiplier: 1, constant: 64))

}

这就是我的代码,我添加了一个 searchController 搜索栏作为 View 的 subview 。我也添加了约束。

每当我在搜索栏中输入内容时,整个内容都会消失,导航栏也会以动画方式消失。

首先它看起来像这样 So it looks like this

然后当我开始打字时,它就不见了 Poof It's gone

最佳答案

searchController1.hidesNavigationBarDuringPresentation = false

关于ios - 为什么在 UISearchBar 上打字时 UISearchController 消失了?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41504483/

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