2015-12-01 75 views
2

我有一個UISearchController嵌入在我的Navigation Bar中,當我點擊它時,整個導航欄將熄滅屏幕,直到我按下屏幕上的另一個區域,然後返回。這裏是a link的視頻。 (視頻mightent已經上傳過所以給它一些時間,鏈接不工作)當我打開我的搜索欄時,導航欄正在隱藏

self.searchController = [[UISearchController alloc] initWithSearchResultsController:nil]; 
    self.searchController.dimsBackgroundDuringPresentation = NO; 
    // Use the current view controller to update the search results. 
    self.searchController.searchResultsUpdater = self; 
    //Setting Style 
    self.searchController.searchBar.barStyle = UIBarStyleBlack; 
    self.searchController.searchBar.barTintColor = [UIColor colorWithRed:49.0/255.0 green:49.0/255.0 blue:61.0/255.0 alpha:1.0]; 
    self.searchController.searchBar.backgroundImage = [UIImage imageNamed:@"BG"]; 
    self.searchController.searchBar.placeholder = @"Search Artists, Songs, Albums etc."; 
    self.searchController.searchBar.keyboardAppearance = UIKeyboardAppearanceDark; 
    [self.searchController.searchBar sizeToFit]; 
    self.definesPresentationContext = YES; 
    self.searchController.searchBar.tintColor = self.view.window.tintColor; 
    [self.searchController.searchBar setTintColor:[UIColor colorWithRed:(226.0/255.0) green:(56.0/255.0) blue:(83.0/255.0) alpha:(1.0)]]; 
    self.searchController.searchBar.delegate = self; 
    self.navigationItem.titleView = self.searchController.searchBar; 
} 

- (void)updateSearchResultsForSearchController:(UISearchController *)searchController{ 
    NSString *searchString = searchController.searchBar.text; 
    NSLog(@"You searched for %@", searchString); 
    [searchResultsTableView reloadData]; 
} 

-(void)searchBarTextDidBeginEditing:(UISearchBar *)searchBar{ 
    [self.view addSubview:searchResultsTableView]; 
} 
+0

您需要包含一些代碼,請看這裏尋求一些建議:http://stackoverflow.com/help/mcve –

+0

對不起,查看更新的答案 –

回答

3

您需要添加以下

self.searchController.hidesNavigationBarDuringPresentation = NO; 

停止激活(ref docs link)時UISearchController隱藏的導航欄。