1

//searchResults 配列を含む tableView が、横向きに回転して縦向きに戻った後、tableView の上部を押し下げて、searchBar を tableView の上部から分離するのはなぜですか。これは、横向きと横向きに回転するたびに繰り返し発生します。これは、検索が開始された後にのみ発生します。searchController がアクティブでない場合、ローテーションでは発生しません。

クラス InitialViewController: UIViewController, UITableViewDataSource, UITableViewDelegate,UISearchResultsUpdating {

@IBOutlet weak var tableView: UITableView!

let searchController = UISearchController(searchResultsController: nil)
let b = searchController.searchBar

b.sizeToFit() // crucial, trust me on this one
b.scopeButtonTitles = ["Drugs", "Tumor", "Target"]
tableView.tableHeaderView = searchController.searchBar
definesPresentationContext = true
searchController.searchResultsUpdater = self
searchController.dimsBackgroundDuringPresentation = false
4

1 に答える 1

0

なんらかの理由で、次の関数を実装すると回転の問題が解決しました。

  override func willAnimateRotationToInterfaceOrientation(toInterfaceOrientation: UIInterfaceOrientation, duration: NSTimeInterval) 
  {
    self.tableView.reloadData()
  }

viewDidLoad 関数の後に上記の func を貼り付けると、私の問題は消えました。理由がわからない。グレン・ティスマン

于 2014-11-26T12:37:48.710 に答える