Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using the iPhones Multi-Touch Keyboard Search Button

I have a regular text field on a view and I'd like to make use of the search button on the iPhones keyboard. For the life of me, I can't figure out how to do this. There doesn't seem to be any event exposed that I can wire up that specifically relates to the search button on the keyboard. I've googled around, but I also haven't found anything related to this subject.

like image 338
senfo Avatar asked Jun 10 '26 02:06

senfo


1 Answers

Make the keyboard display the blue "Search" button by setting the return key type.

myTextField.returnKeyType = UIReturnKeySearch;

Set the delegate of your text field to your controller and implement the 'textFieldShouldReturn:' method.

- (BOOL)textFieldShouldReturn:(UITextField *)textField {
    [textField resignFirstResponder];
    /* Do some searching here */
    return YES;
}
like image 172
kubi Avatar answered Jun 15 '26 10:06

kubi