diff --git a/Source/MICountryPicker.swift b/Source/MICountryPicker.swift index 93829c4..1c97473 100644 --- a/Source/MICountryPicker.swift +++ b/Source/MICountryPicker.swift @@ -155,14 +155,14 @@ open class MICountryPicker: UITableViewController { extension MICountryPicker { override open func numberOfSections(in tableView: UITableView) -> Int { - if searchController.searchBar.isFirstResponder { + if searchController.searchBar.text!.characters.count > 0 { return 1 } return sections.count } override open func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { - if searchController.searchBar.isFirstResponder { + if searchController.searchBar.text!.characters.count > 0 { return filteredList.count } return sections[section].countries.count @@ -179,7 +179,7 @@ extension MICountryPicker { let cell: UITableViewCell! = tempCell let country: MICountry! - if searchController.searchBar.isFirstResponder { + if searchController.searchBar.text!.characters.count > 0 { country = filteredList[(indexPath as NSIndexPath).row] } else { country = sections[(indexPath as NSIndexPath).section].countries[(indexPath as NSIndexPath).row]