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:


– (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text
{  
   if([text isEqualToString:@"\n"])
      {    
           [textView resignFirstResponder];      
           return NO;
    }
   return YES;
}

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.