iPhone Objective-C:键盘不会隐藏resignFirstResponder,有时候 [英] iPhone Objective-C: Keyboard won't hide with resignFirstResponder, sometimes

查看:180
本文介绍了iPhone Objective-C:键盘不会隐藏resignFirstResponder,有时候的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个UITextView,我在命中返回键时调用resignFirstResponder。文本视图 重新签名第一个响应者(文本框中闪烁的光标东西消失),但键盘有时不会消失。



<什么可能导致这个问题?



谢谢!

解决方案

声明 UITextViewDelegate 协议



然后实现这个

   - (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange) range replacementText:(NSString *)text 
{
if([text isEqualToString:@\ n])
{
[textView resignFirstResponder];
返回NO;
}

返回YES;
}


I have a UITextView which I call resignFirstResponder on when the return key is hit. The text view does resign first responder (the flashing cursor thing in the text box goes away), but the keyboard sometimes won't go away.

What could be causing this problem?

Thank you!

解决方案

Declare the UITextViewDelegate protocol

Then implement this

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

    return YES;
}

这篇关于iPhone Objective-C:键盘不会隐藏resignFirstResponder,有时候的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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