Prevent a UISearchDisplayController from hiding the navigation bar

后端 未结 15 1452
南方客
南方客 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:25

    I think the best solution is to implement the UISearchDisplayController yourself.

    It's not that difficult. You only need to implement UISearchBarDelegate for your UIViewController and include a UITableView to display your search results.

    0 讨论(0)
  • 2020-11-27 12:29

    Tried this a different way, without subclassing UISearchDisplayController. In your UIViewController class where you set the delegate for UISearchDisplayController, implement searchDisplayControllerDidBeginSearch: and add use

    [self.navigationController setNavigationBarHidden:NO animated:YES];
    

    Did the trick for me, hope that helps.

    0 讨论(0)
  • 2020-11-27 12:30

    The simplest solution and no hacks.

    @interface MySearchDisplayController : UISearchDisplayController
    
    @end
    
    @implementation MySearchDisplayController
    
    - (void)setActive:(BOOL)visible animated:(BOOL)animated
    {
        [super setActive: visible animated: animated];
    
        [self.searchContentsController.navigationController setNavigationBarHidden: NO animated: NO];
    }
    
    @end
    
    0 讨论(0)
提交回复
热议问题