Yes UITextView
has a delegate protocol you should implement. The delegate protocol is naturally named UITextViewDelegate
. You should notice by browsing the documentation that there is a pattern; For any class Foo
that has a delegate protocol the protocol is always named FooDelegate
, there are no exception.
Now you can as James pointed out intercept text changes using the UITextView
s delegate and dismiss the keyboard. I would however discourage you from doing so, because it violates the Human Interface Guidelines. A UITextView
is intended for editing text with multiple lines of text, intercepting the enter key to mean something elsa than line breaks is not advised.
If you want a text field with only a single line of text, or being dismissed by enter key, then you should instead use a UITextField
, which also have a delegate protocol UITextFieldDelegate
. This protocol has a method intended for what you want:
-(BOOL)textFieldSHouldReturn:(UITextField*)textField {
[textField resignFirstResponder];
return NO;
}