I am at the moment working with UISearchController
and I’ve discovered some awkward conduct of UISearchController
.
Beforehand I did not know there was the showsSearchResultsController
property which helps me to cover searchResultsController
. So I’ve tried to handle it by utilizing searchResultsController?.view.isHidden
. However I’ve discovered that there are rare instances the place I assigned true
to searchResultsController?.view.isHidden
and the view would not get hidden.
Nevertheless, once I used showsSearchResultsController
and assigned false
to it, the searchResultsController
acted as I wished.
The primary code is the code that I used at first (malfunctioned).
Second code is the code that I fastened (labored simply tremendous).
isHidden
.asDriver(onErrorJustReturn: true)
.drive(onNext: { [weak self] in
print("isHidden Earlier than ($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 Earlier than ($0) (self?.searchController.searchResultsController?.view.isHidden)")
self?.appSearchController.showsSearchResultsController = !$0
print("isHidden After ($0) (self?.searchController.searchResultsController?.view.isHidden)")
})
.disposed(by: disposeBag)
In each instances the output of print was
isHidden Earlier than false Non-compulsory(false)
isHidden After false Non-compulsory(true)
By utilizing showsSearchResultsController
I’ve fastened the issue, however I actually wish to know the distinction between two. In my viewpoint I believe two codes look related. Sharing concepts can be very useful to me.