0

I have a UITextField that it set up with autocapitalization, correction, etc., those type of modifiers. I also have a custom toolbar above the keyboard with a "done" button for closing the keyboard.

However, I need the user to be able to enter "returns" in their text for formatting purposes. I have the following code which triggers when the "return" key is pressed:

- (BOOL)textFieldShouldReturn:(UITextField *)textField {
    [textField resignFirstResponder];
    return NO;
}

However, in this case the return key closes the keyboard. Can someone please tell me how to change this code snippet to instead add a blank line to the growing text the user is entering upon clicking "return"?

Thanks!

lnafziger
  • 25,760
  • 8
  • 60
  • 101
jake9115
  • 3,964
  • 12
  • 49
  • 78

1 Answers1

10

UITextField does not support multiline text very well. To support multiline text you probably want to use UITextView

Simon Goldeen
  • 9,080
  • 3
  • 36
  • 45