问题描述
我在 svprogresshud 下的 uitextfield 中输入文本时遇到问题(基本上是一个完整的 uiview-screen 透明 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.
任何帮助将不胜感激.
当没有显示 svprogresshud 时,相同的 uitextfield 可以正常工作.这让我觉得它与第一响应者有关,但我已经尝试在 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.