2016-04-09 10 views
0

私のアプリはユニバーサルデバイスをサポートする必要があります。iPadで検索バーの[キャンセル]ボタンが消える

そして、UISearchControllerを持つビューコントローラがあります。それはiPhoneデバイスでは正常に表示されますが、iPadでは「キャンセル」ボタンが消えます。

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 
} 

私はこの問題の原因を知りたいのですが、どのように解決できるのでしょうか。

助けを求める!どうも。

+0

これは推測です - (.sizeToFit前.showsCancelButtonを移動してみてください) –

+0

@MikeTaverne私はあなたの方法を試して、問題がまだ終了します。 'showsCancelButton'プロパティは' true'です。デフォルトです。私はプロパティが本当であることを強調したい、それで私はそれを書く。 *>。<* –

+0

iPadのキーボードに「キーボードの切捨て」ボタンがある場合、キャンセルボタンは実際には必要ありません。 – tktsubota

答えて

1

この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 
関連する問題