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