gpt4 book ai didi

ios - 搜索栏的“取消”按钮在 iPad 中消失

转载 作者:行者123 更新时间:2023-11-28 06:45:41 24 4
gpt4 key购买 nike

我的应用需要支持通用设备。

其中,有一个具有 UISearchController 的 View Controller 。它可以在 iPhone 设备上正常显示,但在 iPad 上,“取消”按钮消失了。

iPhone

iPad

下面是view controller中searchbar的相关代码。

func configureSearchController() {
self.collectionView!.updateConstraints()
resultsTableController = SearchBookResultTableViewController()
resultsTableController.tableView.delegate = self
searchController = UISearchController(searchResultsController: resultsTableController)
searchController.searchResultsUpdater = self
navigationItem.titleView = searchController.searchBar
searchController.searchBar.sizeToFit()
searchController.dimsBackgroundDuringPresentation = false
searchController.hidesNavigationBarDuringPresentation = false
searchController.searchBar.delegate = self
searchController.searchBar.searchBarStyle = .Minimal
searchController.searchBar.placeholder = "书籍、作者、出版社"
// stress
searchController.searchBar.showsCancelButton = true
definesPresentationContext = true
}

我想知道问题的原因,以及我可以通过什么方式解决。

寻求帮助!谢谢。

最佳答案

我在这个 link 中发现了 iOS 7 中的相同情况。 .我用同样的方法来解决我的问题。但是不知道为什么,新建一个UIView,可以解决吗?它们之间有什么不同?

self.collectionView!.updateConstraints()
resultsTableController = SearchBookResultTableViewController()
resultsTableController.tableView.delegate = self
searchController = UISearchController(searchResultsController: resultsTableController)
searchController.searchResultsUpdater = self
searchController.searchBar.sizeToFit()
searchController.dimsBackgroundDuringPresentation = false
searchController.hidesNavigationBarDuringPresentation = false
searchController.searchBar.delegate = self
searchController.searchBar.searchBarStyle = .Minimal
searchController.searchBar.placeholder = "书籍、作者、出版社"

let SearchView: UIView = UIView(frame: searchController.searchBar.bounds)
SearchView.addSubview(searchController.searchBar)

navigationItem.titleView = SearchView

关于ios - 搜索栏的“取消”按钮在 iPad 中消失,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36511992/

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