2016-01-01 6 views
0

Я запрограммировал создание UISearchController и добавил его в UIView A. У меня также есть UITableView в том же UIView. Я использую UISearchController для поиска через мой UITableView. Когда вы нажимаете на ячейку, UIView B нажимается. UIView A и UIView B имеют UINavigationBar, установленный в HIDDEN. Когда я просто нажимаю на поиск UITableViewCell БЕЗ, все происходит отлично, а UIView B отображается без UINavigationBar.iOS - панель навигации, отображаемая при активном UISearchController

Но когда я ищу с помощью UISearchController, и я нажимаю на UITableViewCell, UINavigationBar отображается в UIView B, хотя я устанавливаю его в метод viewDidAppear.

Вот мой код:

BarsSearchController = [[UISearchController alloc] initWithSearchResultsController:nil]; 
BarsSearchController.searchResultsUpdater = self; 
BarsSearchController.dimsBackgroundDuringPresentation = NO; 
BarsSearchController.searchBar.delegate = self; 
BarsSearchController.searchBar.barTintColor = [UIColor whiteColor]; 
BarsSearchController.searchBar.searchBarStyle = UISearchBarStyleMinimal; 
[searchBarView addSubview:BarsSearchController.searchBar]; 
[searchBarView addConstraint:[NSLayoutConstraint constraintWithItem:BarsSearchController.searchBar 
                  attribute:NSLayoutAttributeTop 
                  relatedBy:NSLayoutRelationEqual 
                  toItem:searchBarView 
                  attribute:NSLayoutAttributeTop 
                 multiplier:1.0 
                  constant:0.0]]; 

[searchBarView addConstraint:[NSLayoutConstraint constraintWithItem:BarsSearchController.searchBar 
                  attribute:NSLayoutAttributeLeading 
                  relatedBy:NSLayoutRelationEqual 
                  toItem:searchBarView 
                  attribute:NSLayoutAttributeLeading 
                 multiplier:1.0 
                  constant:0.0]]; 

[searchBarView addConstraint:[NSLayoutConstraint constraintWithItem:BarsSearchController.searchBar 
                  attribute:NSLayoutAttributeBottom 
                  relatedBy:NSLayoutRelationEqual 
                  toItem:searchBarView 
                  attribute:NSLayoutAttributeBottom 
                 multiplier:1.0 
                  constant:0.0]]; 

[searchBarView addConstraint:[NSLayoutConstraint constraintWithItem:BarsSearchController.searchBar 
                  attribute:NSLayoutAttributeTrailing 
                  relatedBy:NSLayoutRelationEqual 
                  toItem:searchBarView 
                  attribute:NSLayoutAttributeTrailing 
                 multiplier:1.0 
                  constant:0.0]]; 
[searchBarView layoutIfNeeded]; 
self.definesPresentationContext = YES; 
[BarsSearchController.searchBar sizeToFit]; 

Что я здесь отсутствует?

+1

BarsSearchController.hidesNavigationBarDuringPresentation = ДА; –

ответ

0
BarsSearchController.hidesNavigationBarDuringPresentation = YES; 
+0

На самом деле, извините, это не сработает ... значение по умолчанию уже ДА, и панель навигации по-прежнему отображается. Другие идеи? –

0

У меня такая же проблема, чтобы исправить это, я прячу кнопку назад и фона в viewDidLoad:

- (void)viewDidLoad 
{ 
    [super viewDidLoad]; 
    self.navigationItem.hidesBackButton = YES; 
    [[[self navigationController] navigationBar] setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault]; 
    [[[self navigationController] navigationBar] setShadowImage:[UIImage new]]; 
    [[[self navigationController] navigationBar] setTranslucent:YES]; 
} 

и я скрыть Панель навигации в viewDidAppear:

- (void)viewDidAppear:(BOOL)animated 
{ 
    [super viewDidAppear:animated]; 
    [[self navigationController] setNavigationBarHidden:YES]; 
} 
Смежные вопросы