objective-c - objective - uisearchbar search results button




UISeachBar detect when user press Search button (2)

Have you tried this delegate

Objective-C:

- (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar

Swift:

func searchBarSearchButtonClicked(searchBar: UISearchBar)

See the documentation for any searchbar delegates. https://developer.apple.com/documentation/uikit/uisearchbardelegate

I try to get notification when the Search button is clicked in the keyboard in the UISearchBar with this :

    - (BOOL)textFieldShouldReturn:(UITextField *)textField{

        return YES;
    }

But this method won't call when I press the Search button.


If you want to do something upon 'search' button get clicked then, Try this method

  • (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar

Tells the delegate that the search button was tapped.





uitextfield