1
votes

I want to hide the keyboard after typing the content into the UITextView but i can not do this by default like UITextField. Is there any way to hide the keyboard, Rightnow i put the button which can help me out.If any default way to hide it then please tell me.

2
If my ans is right then make it right by just click on true check mark.Chetan Bhalara

2 Answers

1
votes

Use following code for hide the keyboard from text view when user enter "\n"(new line) means press "Done" or "return" button.

- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text {

    if([text isEqualToString:@"\n"]) {
        [textView resignFirstResponder];
        return NO;
    }

    return YES;
}

Example1 and Example2.

1
votes
[textView resignFirstResponder];

Here is your detail answer