5

Possible Duplicate:
How to create a multiline UITextfield?

UITextField delegate will capture return key: - (BOOL)textFieldShouldReturn:(UITextField *)textField

but it won't do multiline like UITextView can. But UITextView, can it capture return key?

I need to capture key events: (return) and do multiline: "\n".... What can I do? thx

Community
  • 1
  • 1
jdl
  • 6,151
  • 19
  • 83
  • 132
  • You should split this into two separate questions. – esqew May 02 '12 at 23:35
  • 2
    I need to capture return and do multiline with either UITextField or UITextView. Neither, from what I see, can do both features... ?? – jdl May 02 '12 at 23:36

1 Answers1

9

A quick google search for "UITextView detect return" came up with this thread:

UITextView (editing) - detecting that next line event occured

(for convenience sake, I've posted the code below)

- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text;
{
    if ( [text isEqualToString:@"\n"] ) {
        //Do whatever you want
    }
    return YES;
}
Community
  • 1
  • 1
orangething
  • 708
  • 5
  • 16