I'm trying to dismiss the search controller before a segue is performed. I have added the following code to the prepare
portion of my view controller:
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
searchController.isActive = false
}
This works perfectly fine at dismissing the search controller, but once the search controller has been dismissed the segue doesn't perform. It's as if dismissing the search controller stops the rest of the segue.
Is there a different way to dismiss a UISearchController
that doesn't interrupt a segue's flow while still calling all of the accompanying delegate methods?
Are you triggering the segue programmatically or through a storyboard?
If the former, you should dismiss the search controller before calling performSegueWithIdentifier:sender:
by moving that call out of the function above and above your performSegueWithIdentifier:sender:
call.
If the latter and you can't find a place to dismiss it elsewhere, you could try moving the dismissal to shouldPerformSegueWithIdentifier:sender: although you might run into the same issue there.