-1

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'

Titouan de Bailleul
  • 12,920
  • 11
  • 66
  • 121

3 Answers3

0

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;
WhiteTiger
  • 1,691
  • 1
  • 18
  • 23
0
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;

}
Titouan de Bailleul
  • 12,920
  • 11
  • 66
  • 121
Shantanu
  • 3,086
  • 3
  • 25
  • 32
0

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;
}
Titouan de Bailleul
  • 12,920
  • 11
  • 66
  • 121
k.shree
  • 119
  • 1
  • 2
  • 12