The method below uses the return key to close the keyboard of the UITextView.
In your controller, set the UITextView delegate yourself for example:
myTextView.delegate=self;
Then add this method:
- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range
replacementText:(NSString *)text
{
if ([text isEqualToString:@"\n"]) {
[textView resignFirstResponder];
return FALSE;
}
return TRUE;
}
This should work if you do not use the Return key as a true return key (for example, add a new line).
source
share