2017-05-10 8 views
0

をキャンセルテーブルビューに、検索バーが完全にtableHeaderViewをカバーするとボタンが表示さadded.And私はレイヤーを見たことができない、まだそこに、ちょうど拡大searchbar.Anyoneでくるみボタンは?これを解決する方法を事前に感謝を知っています!検索バーのフレームは、私が検索を終了し、バックキャンセルボタンをクリックした後UIView.ThenにサブビューがTableHeaderView.ButとしてのUIViewを設定するように私は私の検索バー(左)とボタン(右)を追加ボタン

self.searchController = [[UISearchController alloc]initWithSearchResultsController:nil]; 
self.searchController.searchResultsUpdater = self; 
UIView *view = [[UIView alloc]initWithFrame:CGRectMake(0, 0, WinWidth, 40)]; 
self.searchController.searchBar.frame = CGRectMake(0, 0, WinWidth-50, 40); 
UIButton *filterBtn = [[UIButton alloc]initWithFrame:CGRectMake(WinWidth-30, 10, 20, 20)]; 

filterBtn setBackgroundImage:[UIImage imageNamed:@"arrow_expend_down"] forState:UIControlStateNormal]; 
[view addSubview:self.searchController.searchBar]; [self.searchController.searchBar addSubview:filterBtn]; 
self.searchController.searchBar.barTintColor = [self colorWithRGB:0xf2f2f2 alpha:1]; 
[view addSubview:filterBtn]; 
view.backgroundColor =self.searchController.searchBar.barTintColor; self.tableView.tableHeaderView = view; 
+0

シェアを試すいくつかのコード – ajjjjjjjj

+0

コード等: 'self.searchController = [[UISearchController ALLOC] initWithSearchResultsController:なし]。 self.searchController.searchResultsUpdater = self; UIView * view = [[UIView alloc] initWithFrame:CGRectMake(0、0、WinWidth、40)]; self.searchController.searchBar.frame = CGRectMake(0、0、WinWidth-50,40); UIButton * filterBtn = [[UIButton ALLOC] initWithFrame:CGRectMake(WinWidth-30、10、20、20)]。 '' ' – JoeyYYF

+0

と: ' '' [filterBtn setBackgroundImage:[UIImage imageNamed: "arrow_expend_down" @] forState:UIControlStateNormal]; [表示するaddSubview:self.searchController.searchBar]; [self.searchController.searchBar addSubview:filterBtn]; self.searchController.searchBar.barTintColor = [自己colorWithRGB:0xf2f2f2アルファ:1]; [表示するaddSubview:filterBtn]; view.backgroundColor = self.searchController.searchBar.barTintColor; self.tableView.tableHeaderView = view; '' ' – JoeyYYF

答えて

0

try:tableView.tableHeaderView.contentMode = UIViewContentModeCenter;

+0

試しましたが動作しません、キャンセルボタンをクリックするとデリゲートメソッドまたは他の何かがsearchBarのフレームを変更するが、私はドキュメントで見つけることができませんでした。 – JoeyYYF

0

この

[self.searchController.searchBar sizeToFit]; 
+0

これは意味がないようですが、ボタンはまだsearchBarによって隠されています – JoeyYYF

関連する問題