2015-12-28 45 views
3

我遇到iOS9,那裏的範圍吧是的UISearchBar明顯落後於權當ViewController中出現的第一次這種奇怪的行爲:範圍欄可見背後的UISearchBar

Bug

按下後「搜索」的UISearchBar的行爲如預期(UISearchBar移動到頂部與下面的範圍欄)。搜索完成或後擊中取消它返回到狀態,我想從一開始就具有:

Subsequent correct look

在viewDidLoad方法我初始化UISearchController如下:

self.searchController = [[UISearchController alloc] initWithSearchResultsController:nil]; 
    self.searchController.searchResultsUpdater = self; 
    self.searchController.dimsBackgroundDuringPresentation = NO; 
    self.searchController.searchBar.autocorrectionType = UITextAutocorrectionTypeNo; 
    self.searchController.searchBar.autocapitalizationType = UITextAutocapitalizationTypeNone; 
    [self.searchController.searchBar sizeToFit]; 

    self.definesPresentationContext = YES; 
    self.tableView.tableHeaderView = self.searchController.searchBar; 

    self.searchController.searchBar.delegate = self; 
    self.searchController.searchBar.scopeButtonTitles = @[[self titleForScopeButton:ScopeButtonIdNameDesc], 
                  [self titleForScopeButton:ScopeButtonIP]]; 

任何想法?

回答

0

我沒有在那個應用程序上工作過,忘了我在appDelegate的didFinishLaunchingWithOptions中設置了UISearchBar的整體外觀。

[[UISearchBar appearance] setSearchBarStyle:UISearchBarStyleMinimal]; 
[[UISearchBar appearance] setBackgroundColor:[PCConstantsGUI tintColor]]; 
[[UISearchBar appearance] setTintColor:[PCConstantsGUI tintColor]]; 

罪魁禍首引起渲染的問題是「UISearchBarStyleMinimal」,看上去俏皮之前,我不得不更換UISearchController過時的UISearchDisplayController。