Using the 'Done' button as the return key

734 Views Asked by At

I would like to know if it would be possible to use the 'Done' key of the keyboard as the return key ?

Example :

You are in a search field, you type whatever you want to search for and then instead of tapping on the return key of the keyboard, I would like the user to be able to start the search by tapping on the 'Done' key juste above the keyboard.

Update :

I don't want to change the text or the aspect of the return key. I want to launch the search with the 'Done' blue button that is in the small bar above the keyboard, next to 'Previous' and 'Next'

3

There are 3 best solutions below

0
WhiteTiger On

I just implement the following method:

from UITextFieldDelegate

textFieldShouldReturn:

Asks the delegate if the text field should process the pressing of the return button.

- (BOOL)textFieldShouldReturn:(UITextField *)textField;
0
Shantanu On
textField.returnKeyType=UIReturnKeyDone;

Add this to your text field's delegate to remove the keyboard when it's pressed:

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

    [textField resignFirstResponder];

    return YES;

}
0
k.shree On

Try this : It will help you... First set delegate to your all textfields than write this method:

- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text {

    if([text isEqualToString:@"\n"]) {
        [textView resignFirstResponder];
        return NO;
    }

    return YES;
}