I can create a visibility panel for the UISearchController and set their names
resultSearchController = ({ let controller = UISearchController(searchResultsController: nil) controller.searchResultsUpdater = self controller.dimsBackgroundDuringPresentation = false controller.searchBar.showsScopeBar = true controller.searchBar.scopeButtonTitles = ["One", "two", "three"] controller.searchBar.sizeToFit() self.tableView.tableHeaderView = controller.searchBar return controller })()
But how do I really sort using the value bar. My current sorting method is as follows
func updateSearchResultsForSearchController(searchController: UISearchController) { filteredTableData.removeAll(keepCapacity: false) let searchPredicate = NSPredicate(format: "SELF CONTAINS[c] %@", searchController.searchBar.text) let array = (tableData as NSArray).filteredArrayUsingPredicate(searchPredicate) filteredTableData = array as! [String] tableView.reloadData() }
ios uitableview swift uisearchcontroller
Apoorv mote
source share