I am working on one specific field in form. When I enter the text that has less than 3 letters then should disable the search button on keyboard. When it has 3 or more it should enable it. I tried by accessing UISearchBar property but it doesnt work.
This is what I wrote:
func searchBar(_ searchBar: UISearchBar, textDidChange searchText: String) {
let textFieldInsideSearchBar = searchBar.value(forKey: "searchField") as? UITextField
if itsBicApiCallEnabled && searchText.count >= 3 {
textFieldInsideSearchBar?.enablesReturnKeyAutomatically = true
} else {
textFieldInsideSearchBar?.enablesReturnKeyAutomatically = false
}
}
I tried by accessing UISearchBar property but it doesnt work.