Posts

Showing posts with the label searchbar

search result not work went add tableviewcell

Image
search result not work went add tableviewcell Search bar is woking very well until I add custom tableview cell. It breaks when I search a keyword matching with a array. When I search wrong, it doesn't break. var filteredArray = [String]() var searchController = UISearchController() var result = UITableViewController() override func viewDidLoad() { super.viewDidLoad() searchController = UISearchController(searchResultsController: result) tableView.tableHeaderView = searchController.searchBar searchController.searchResultsUpdater = self result.tableView.delegate = self result.tableView.dataSource = self result.tableView.register(UITableView.self, forCellReuseIdentifier: "Cell") } //config seachbar func updateSearchResults(for searchController: UISearchController) { filteredArray = array.filter( { (array : String) -> Bool in if array.contains(searchController.searchBar.text!) { return true } else ...