Question

On my iPhone app I'm using a UISearchBar (without a Search Display Controller). I have my own 'Search' button as a UIButton and therefore on the keyboard that pops up when editing begins on a UISearchBar I would like to constantly hide the 'Search' button on it as it is unusable. How could I go about doing this without the Search Display Controller?

Or instead - is it possible to continue using my UISearchBar and UIButton 'Search', and also get the keyboard 'Search' button to work as well? I have tried -

(void)searchBarSearchButtonClicked:(UISearchBar *)searchBar

However my UISearchBar is called 'searchbar' and therefore isn't responding to that (changing the searchBar to searchbar doesn't work either). When I instead use a UISearchBar with a Search Display Controller is works perfectly - however, I don't want the new table view that it opens on editing - or is there a way to prevent this too?

Thanks in advance!

Benji

--EDIT: SOLVED. I just used a textfield instead upon the searchbar so it looks similar.

Was it helpful?

Solution

SOLVED. I just used a textfield instead upon the searchbar so it looks similar.

OTHER TIPS

If you want to change UISearchBar's textfield, you may use the following code:

UITextField *textField = [searchBar.subviews objectAtIndex:1];
textField.returnKeyType = UIKeyboardTypeDefault;
textField.leftView = nil;
textField.delegate = self;

But if you want to have an edit bar, a customized one is more appropriate. For example, create a toolbar and add a UITextField, a Flexible Space and a UIBarButtonItem with text "send" on it. Then it will look like the edit bar in SMS app.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top