UITextField / UITextView: I need to be able to detect user "return" key, and I need to be able to do multiline... what can do both?
cocoa-touch, objective-c
Solution
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;
}
Problem
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