Reputation: 443
Is there a way to disable only the search field if the scope title is 'All', but enable it when you click on the other scope titles?
I try setting the searchBar.isUserInteractionEnabled = false
but it disables the scope title bar as well. Therefore, I'm unable to interactive with the scope titles to reenable the search field.
Thanks in advance.
Upvotes: 0
Views: 557
Reputation: 318804
There's no public API to enable or disable the text field in the search bar. However, you have a solution.
When the "All" scope button is selected, resign the search bar as the first responder. That should dismiss the keyboard. Set the text
property to the empty string.
Implement the searchBarShouldBeginEditing
delegate method. Return false
if the "All" scope button is selected, true
for the others. This will prevent the search field from becoming active once "All" has been selected.
Optionally you can update the search bar's prompt
as needed to help the user understand why nothing happens when they try to type into the search bar while "All" is selected.
Upvotes: 3