在textView中,当我点击完成按钮时键盘没有退出 [英] In textView when I click on done button the keyboard is not resigning

查看:296
本文介绍了在textView中,当我点击完成按钮时键盘没有退出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

单击完成按钮后,我在调整键盘时出现问题。我正在使用textView

I'm getting problem in resigning the keyboard after clicking done button. I'm using textView

-(BOOL)textViewShouldReturn:(UITextView *)textView
{
    if(textView == addressView)
    {
        if(isNotif)
        {
            [self setViewMovedUp:NO];
        }
        textView.text= [textView.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
        [addressView resignFirstResponder];
    }
    return YES;
}

光标不是键盘辞职,而是在文本字段中换行。
请帮助我。

Instead of keyboard resigning the cursor is coming to new line in the text field. Please help me.

谢谢
Praveena。

Thank You Praveena.

推荐答案

使用以下委托

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

通常在textView中,返回键用于将\ n添加到文本中,最好在UItextView的顶部添加一些其他按钮并在那里编写辞职功能。

Usually in textView the return key is use to add \n to the text, so its better to add some other button to top of the UItextView and code the resigning function there.

编辑:

没有这样的委托 - (BOOL)textViewShouldReturn:(UITextView *)textView

这篇关于在textView中,当我点击完成按钮时键盘没有退出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆