setting enablesReturnKeyAutomatically on UISearchBar

Posted by Erik Carlson on Stack Overflow See other posts from Stack Overflow or by Erik Carlson
Published on 2010-05-20T07:53:19Z Indexed on 2010/05/20 8:10 UTC
Read the original article Hit count: 660

Filed under:
|

Hi There,

I'm writing for iphone OS 3.1.3. I want the search button in the keyboard from my UISearchBar to have the search button enabled all the time. If this was any old UITextField (not a search bar) the property would be enablesReturnKeyAutomatically.

I have tried setting this using the example given at http://discussions.apple.com/thread.jspa?messageID=8457910

which suggests:

UITextField *searchTextField ; 
searchTextField = [[searchBar subviews]objectAtIndex:0];
searchTextField.enablesReturnKeyAutomatically = NO ;

Should work.

unfortunately it crashes:

2010-05-20 08:36:18.284 ARemote[5929:207] *** -[UISearchBarBackground setEnablesReturnKeyAutomatically:]: unrecognized selector sent to instance 0x3b31980
2010-05-20 08:36:18.284 ARemote[5929:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[UISearchBarBackground setEnablesReturnKeyAutomatically:]: unrecognized selector sent to instance 0x3b31980'

I have also tried

((UITextField *)[(NSArray *)[searchBar subviews] objectAtIndex:0]).enablesReturnKeyAutomatically = NO;</code>

Which gives similar results.

Any ideas?

Cheers Erik

© Stack Overflow or respective owner

Related posts about iphone

Related posts about uisearchbar