2016-02-09 9 views
7

searchHarをtableHeaderViewの中に配置しました。 すべてがiphone 6ではうまく動作しますが、iphone 5sではこの奇妙な結果が得られますか?searchBarがセクションヘッダービューでオーバーラップしました

override func viewDidLoad() { 
    super.viewDidLoad() 
    tableView.delegate = self 
    tableView.dataSource = self 
    tableView.sectionIndexColor = Constants.Colors.ThemeGreen 
    tableView.sectionIndexBackgroundColor = UIColor.clearColor() 
    tableView.sectionIndexTrackingBackgroundColor = UIColor.clearColor() 
    tableView.contentInset = UIEdgeInsetsMake(0, 0, CGFloat(Constants.Dimensions.TabBarHeight), 0) 
    resultSearchController = UISearchController(searchResultsController: nil) 
    resultSearchController.searchResultsUpdater = self 
    resultSearchController.dimsBackgroundDuringPresentation = false 
    resultSearchController.definesPresentationContext = true 
    tableView.tableHeaderView = resultSearchController.searchBar 
    resultSearchController.searchBar.sizeToFit() 

//Fetch data for the first time 
    do{ 
     try fetchedResultsController.performFetch() 
     listHeaderView?.count = "\(fetchedResultsController.fetchedObjects!.count)" 
    }catch{ 
     print("Error - Couldn't fetch list") 
    } 
  • 注:私はデータ

enter image description here

+0

追加する前にsizeToFitを呼び出した後でも私はまだこの問題に直面しています –

答えて

3

を取得するためにNSFetchedResultControllerを使用しています。ここソリューションです。 searchToをtableHeaderViewに配置した後にsizeToFit()を呼び出さずにBEFOREを呼び出します。 は地獄は、私は疑問に思う...シーンの背後で何が起こっているのか...

resultSearchController.searchBar.sizeToFit() //Important to call sizeToFit BEFORE adding it to tableHeaderView or you get layout issues 
tableView.tableHeaderView = resultSearchController.searchBar 
+0

、私はこの問題に直面しています... –

0

それは仕事が...他に何が今動いていないようにみえないだけのコードの行の下にいるようです。

self.tableView.beginUpdates() 
     // self.tableView.setTableHeaderView(headerView: self.filterView!) 
     //self.tableView.reloadData() 
     self.tableView.layoutIfNeeded() 
     self.tableView.layoutSubviews() 
     self.tableView.endUpdates() 

テーブルのサイズを変更するか、上記のコードを呼び出す必要があるたびに制約を変更します。

0

は、それはあなたがまた、私はそれはあなたのコードのために働くと思う

searchControl.searchBar.clipToBounds = true 

と同じように試すことができます

resultSearchController.clipToBounds = true

を働くこと、これを試してみてください。

関連する問題