Make the controller a delegate of UITextField / UITextView in IB or from code such as textField.delegate = self;
Editted: For this you need to declare the controller as a delegate of UITextFieldDelegate / UITextViewDelegate as
@interface Controller : <UITextFieldDelegate> { ...
then override the method:
-(BOOL)textFieldShouldReturn:(UITextField *)textField{ [textField resignFirstResponder]; return YES; }
for UITextField and
-(BOOL)textViewShouldEndEditing:(UITextView *)textView{ [textView resignFirstResponder]; return YES; }
for UITextView
skonb
source share