As long as you set the type of return key, it does not change the behavior of the text view. In Return it will add a new line to the text view. Therefore, if you do not want your textual representation to be multi-line, you can capture \n and resignFirstResponder .
- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text { if ( [text isEqualToString:@"\n"] ) { [textView resignFirstResponder]; } return YES; }
On the side of the note, textViewShouldEndEditing: is called after you have canceled your status as the first responder.
If you want to keep newline characters in a text view, you should consider using the inputAccessoryView text view. An example of this is here .
Deepak danduprolu
source share