gpt4 book ai didi

ios - iOS 垂直居中搜索 Controller

转载 作者:行者123 更新时间:2023-11-30 11:07:00 25 4
gpt4 key购买 nike

我用代码以编程方式添加了 UISearchController

 let searchController = UISearchController(searchResultsController: nil)

override func viewDidLoad() {
super.viewDidLoad()

searchController.searchResultsUpdater = self
searchController.obscuresBackgroundDuringPresentation = false
searchController.searchBar.placeholder = "Введіть значення для пошуку"
searchController.searchBar.backgroundColor = .white
navigationItem.searchController = searchController
definesPresentationContext = true

}

但是好像没有垂直居中。我该如何修复它?

enter image description here

最佳答案

将 SearchController 连接到 TableView 而不是 NavigationItem

tableView.tableHeaderView = searchController.searchBar

关于ios - iOS 垂直居中搜索 Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52611131/

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