UITextField没有得到键盘输入 [英] UITextField not getting keyboard input

查看:121
本文介绍了UITextField没有得到键盘输入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很难在 SVProgressHUD 下将文本输入到UITextField中(基本上是一个完整的UIView)屏幕透明的UIWindow和一些UIView子视图显示文本和自定义绘制的进度条。)

I'm having troubles entering text into an UITextField under a SVProgressHUD (Basically an UIView with a full-screen transparent UIWindow and some UIView subviews showing text and a custom-drawn progress bar).

我的问题是UITextField显示闪烁的光标和键盘显示,但是当我点击一个键时,没有任何内容输入到文本字段中。
我只看到光标的闪烁中断就像正常一样。
有趣的是,后退(删除)键有效(它确实删除了UITextView中的最后一个字母),但没有任何其他键。

My problem is that the UITextField displays the blinking cursor and the keyboard shows, but when I tap a key, nothing is entered into the text field. I only see that the cursor's blinking interrupts just like normal. Interestingly enough, the back (delete) key works (it really deletes the last letter in the UITextView), but not any other key.

我是使用iOS 6.

I'm using iOS 6.

任何帮助都将受到高度赞赏。

Any help would be highly appreciated.

编辑:
相同的UITextField没有显示SVProgressHUD时工作正常。这让我觉得它与第一个响应者有关,但我已经尝试在SVProgressHUD的每个窗口和子视图上调用 resignFirstResponder ,但它仍然不起作用。

The same UITextField works fine when there's no SVProgressHUD displayed. This makes me think it has something to do with the first responder, but I have already tried calling resignFirstResponder on every window and subview of the SVProgressHUD and it still does not work.

推荐答案

我终于找到了问题:
SVProgressHUD调用 makeKeyAndVisible 当它被初始化时,因为它想要接收键盘通知以重新定位。我查看了关键窗口实际上是什么并找到了:

I finally found the problem: SVProgressHUD calls makeKeyAndVisible when it's initialized, because it wants to receive keyboard notifications for repositioning. I looked up what the "Key Window" actually is and found out:


...关键窗口响应用户输入...

...The key window responds to user input...

现在,由于SVProgressHUD的UIWindow是keyWindow,我的另一个窗口(包含UITextField)没有得到用户输入。

Now, as the UIWindow of the SVProgressHUD was the keyWindow, my other window, which contained the UITextField did not get the user input.

我终于在AppDelegate的窗口调用 makeKeyWindow ,一切正常。

I finally call makeKeyWindow on the AppDelegate's window and everything is working fine.

我希望这可以帮助任何有类似问题的人。

I hope this helps anyone with similar problems.

这篇关于UITextField没有得到键盘输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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