UITextField not getting keyboard input(UITextField 没有得到键盘输入)
问题描述
我在 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.
这篇关于UITextField 没有得到键盘输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:UITextField 没有得到键盘输入
基础教程推荐
- Kivy Buildozer 无法构建 apk,命令失败:./distribute.sh -m “kivy"d 2022-01-01
- 当从同一个组件调用时,两个 IBAction 触发的顺序是什么? 2022-01-01
- 如何在没有IB的情况下将2个按钮添加到右侧的UINavigationbar? 2022-01-01
- 如何在 iPhone 上显示来自 API 的 HTML 文本? 2022-01-01
- 如何让对象对 Cocos2D 中的触摸做出反应? 2022-01-01
- UIWebView 委托方法 shouldStartLoadWithRequest:在 WKWebView 中等效? 2022-01-01
- 在 gmail 中为 ios 应用程序检索朋友的朋友 2022-01-01
- Android:对话框关闭而不调用关闭 2022-01-01
- 如何在 UIImageView 中异步加载图像? 2022-01-01
- android 应用程序已发布,但在 google play 中找不到 2022-01-01