setting enablesReturnKeyAutomatically on UISearchBar
- by Erik Carlson
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