A little background on the setting of our views:
Inside a NavigationController
, we have a UITabBarController
(with 3 tabs) with a UIViewController
that has a UISearchController
.
There is an error that if we leave the UISearchController
active and switch to another view, when we return to the search view the entire screen is black.
However, when the UISearchController
is not active and we switch views this does not happen.
We have tried to set the controller to not be active when segueing between views; however, when the UISearchController
is active none of the segueing events get called (no log prints appear from viewWillDissapear
, viewWillAppear
, etc.)
Looking on other threads, we tried setting self.definesPresentationContext = true
but that does not work.
Has anyone else had this problem or know how to fix it?
The initializer to UISearchController can take an argument that can specify a different view controller to show the search results. I think the most common use case is to show the search results in the same view controller that has the table view. Passing nil indicates that we do not want another view controller to show the search results.
Don’t use a UISearchContainerViewController on iOS. Specify a second view controller for displaying search results when you call init (searchResultsController:). When the user interacts with the search bar, the search controller automatically displays the results controller with the results you specify.
The UISearchController was introduced a couple years ago in iOS 8 to replace the now deprecated UISearchDisplayController. In the new search controller, it is easier to add search to your table views. As of Xcode 8.1, the UISearchController has not been added to Interface Builder, so you have to add it programmatically.
Your users will appreciate searches that are intelligent and fast. If you’ve worked with searching table views in iOS in the past, you may be familiar with UISearchDisplayController. Since iOS 8, Apple has deprecated this class in favor of UISearchController, which simplifies the entire search process.
Try to set the searchbarController active like this
self.resultSeachController.active = false
before you move on the next View
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With