Skip to Content
0
May 27, 2020 at 11:17 AM

searchController.isActive returns false for FUISearchController

231 Views

Hi,
I've implemented the FUISearchController with scope buttons, but the searchController.isActive returns false the first time the searchController appears, making my isFiltering also false. The strange thing is that changing just changing the searchController type to UISearchController, everything works like it should. When starting to type, the property is set to true though.

Could it be that this property is overridden in the implementation of FUISearchController?

Some code:

private var searchController = FUISearchController(searchResultsController: nil

private var isSearching: Bool { let searchBarScopeIsFiltering = searchController.searchBar.selectedScopeButtonIndex != 0 return searchController.isActive && (!isSearchBarEmpty || searchBarScopeIsFiltering)
}

ViewDidLoad

searchController.searchBar.delegate = self
searchController.searchResultsUpdater = self
searchController.hidesNavigationBarDuringPresentation = true
searchController.obscuresBackgroundDuringPresentation = false
searchController.searchBar.placeholder = "Search for customers"
searchController.searchBar.scopeButtonTitles = customerSearchTypes.allCases.map { $0.rawValue }
navigationItem.searchController = searchController