I have searched for hours trying to solve my problem, but i could not find any solutions.
My problem is that i have a SearchBar inside my navigation bar. I did setup my SearchBar like this:
lazy var searchBar = UISearchBar(frame: CGRect.zero)
override func viewDidLoad() {
super.viewDidLoad()
searchBar.delegate = self
searchBar.placeholder = "Search"
navigationItem.titleView = searchBar
}
func searchBarTextDidBeginEditing(searchBar: UISearchBar) {
print("Did run")
}
Your delegate function is just a bit different from the right one, at the parameter. It should be:
func searchBarTextDidBeginEditing(_ searchBar: UISearchBar) {
//code
}