Reputation: 1587
searchController move to top when I write text but when I clicking tableview cell I want same behaviour. searchController need to set top as its work on appstore app. like as shown below I tap on tableview cell so I want searchController to moves top. so what I have to write in my code.thanks
Upvotes: 2
Views: 124
Reputation: 1758
Make the UITextField
in the UISearchBar
become the first responder() when you tap the cell.
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
if let searchField = searchController.searchBar.value(forKey: "searchField") as? UITextField {
searchField.becomeFirstResponder()
}
}
Upvotes: 4