0
我的应用需要支持通用设备。搜索栏的“取消”按钮在iPad中消失
而且,在那里,有一个视图控制器有UISearchController。它可以在iPhone设备上正常显示,但在iPad中,“取消”按钮消失。
它是关于搜索栏在视图控制器,以下相关的代码。
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
}
我想知道问题的原因,以及我能以哪种方式解决它。
寻求帮助!谢谢。
这是一个猜测 - 尝试移动.sizeToFit前.showsCancelButton() –
@MikeTaverne我尝试用自己的方式,问题依然存在。 'showsCancelButton'属性是'true',这是默认值。我只想强调属性是真实的,所以我写了它。 *>。<* –
由于iPad键盘上有“键盘解除”按钮,取消按钮并不是必须的。 – tktsubota