I'm currently working with UISearchController and I've found out some awkward behavior of UISearchController.
Previously I didn't know there was the showsSearchResultsController property which helps me to hide searchResultsController. So I've tried to manage it by using searchResultsController?.view.isHidden. But I've found out that there are infrequent cases where I assigned true to searchResultsController?.view.isHidden and the view doesn't get hidden.
However, when I used showsSearchResultsController and assigned false to it, the searchResultsController acted as I wanted.
The first code is the code that I used at first (malfunctioned).
Second code is the code that I fixed (worked just fine).
isHidden .asDriver(onErrorJustReturn: true) .drive(onNext: { [weak self] in print("isHidden Before \($0) \(self?.searchController.searchResultsController?.view.isHidden)") self?.appSearchController.searchResultsController?.view.isHidden = $0 print("isHidden After \($0) \(self?.searchController.searchResultsController?.view.isHidden)") }) .disposed(by: disposeBag) isHidden .asDriver(onErrorJustReturn: true) .drive(onNext: { [weak self] in print("isHidden Before \($0) \(self?.searchController.searchResultsController?.view.isHidden)") self?.appSearchController.showsSearchResultsController = !$0 print("isHidden After \($0) \(self?.searchController.searchResultsController?.view.isHidden)") }) .disposed(by: disposeBag) In both cases the output of print was
isHidden Before false Optional(false) isHidden After false Optional(true) By using showsSearchResultsController I've fixed the problem, but I really want to know the difference between two. In my point of view I think two codes look similar. Sharing ideas would be very helpful to me.