Prevent a UISearchDisplayController from hiding the navigation bar

后端 未结 15 1638
南方客
南方客 2020-11-27 11:59

Whenever a user begins editing a UISearchDisplayController\'s search bar, the search controller becomes active and hides the view\'s navigation bar while presen

15条回答
  •  孤独总比滥情好
    2020-11-27 12:07

    This seem to solve it for me. Tested in both iOS5/6.1. No visual issues that I could see.

    - (void)viewDidAppear
    {
        [super viewDidAppear];
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillAppear:) name:UIKeyboardWillShowNotification object:nil];
    }
    
    -(void)viewWillDisappear:(BOOL)animated{
        [super viewWillDisappear:animated];
        [[NSNotificationCenter defaultCenter] removeObserver:self];
    }
    
    - (void)keyboardWillAppear:(NSNotification *)notification
    {
        [self.navigationController setNavigationBarHidden:NO animated:NO];
    }
    
    -(void)viewDidLayoutSubviews{
        [self.navigationController setNavigationBarHidden:NO animated:NO];
    }
    

提交回复
热议问题