Basically UITextView is for Multi line Text. However if you want to hid the keyboard when the user presses the Return Key using the following snippet:

  1. - (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text
  2. {  
  3.    if([text isEqualToString:@"n"])
  4.       {    
  5.  
  6.            [textView resignFirstResponder];      
  7.            return NO;
  8.     }
  9.    return YES;
  10. }

Here we implement the shouldChangeTextInRange method which gets called whenever a character is typed in the text box. So when the user presses the Return Key on the Keyboard, it translates into a newline(n) character. Here we scan for the n (newline) character, and if found we then dismiss the keyboard.

This shouldChangeTextInRange is part of the UITextViewDelegate, so make sure that is defined in the .h file.