Navigation bar issue when search is active and push to next view controller

Objective-C

-(void)viewWillDisappear:(BOOL)animated{
    if (@available(iOS 13.0, *)) {
        [self.navigationController.view setNeedsLayout]; 
        [self.navigationController.view layoutIfNeeded];
    }
}

Swift

func viewWillDisappear(_ animated: Bool) {
    if (@available(iOS 13.0, *)) {
         self.navigationController?.view.setNeedsLayout()     
         self.navigationController?.view.layoutIfNeeded()
    }
}

I had the same problem. It seems that something make the navigation bar visible when search controller was active in previous view although I hide the navigation bar in viewWillAppear().

I solved it by hide the navigation bar again in viewWillLayoutSubviews():

override func viewWillLayoutSubviews() {
    super.viewWillLayoutSubviews()
    navigationController?.setNavigationBarHidden(true, animated: false)
}

You can fix this issue by making search controller inactive, then navigate to your details view controller after some delay.

Try following code in you didSelect method which will help you to hide navigation bar when search controller is active.

searchController.isActive = false

DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
    self.navigationController?.navigationBar.isHidden = true
    self.navigationController?.isNavigationBarHidden = true
    self.navigationController?.pushViewController(<YourViewController>, animated: true)
}

You must required delay to navigate otherwise it's give you warning in console regarding navigation controller presentation process.

So, this code first make your search controller inactive and then navigate to your next view controller.