开发者

UITextView keyboard hidding problem

开发者 https://www.devze.com 2023-04-04 05:20 出处:网络
I want to hide the keyboard after typing the content into the UITextVie开发者_高级运维w but i can not do this by default like UITextField. Is there any way to hide the keyboard, Rightnow i put the but

I want to hide the keyboard after typing the content into the UITextVie开发者_高级运维w 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.


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.


[textView resignFirstResponder];

Here is your detail answer

0

精彩评论

暂无评论...
验证码 换一张
取 消