XCode 4. 键盘在 iPad 上不会隐藏
我的 iPad 应用程序出现问题。
我在社交网络(facebook、twitter 等)中进行授权,以从应用程序发布信息。几个网络视图相互改变(登录、帖子内容、验证码)。他们有文本字段,我必须显示键盘。发布后,我返回到一些带有发布信息的开始视图。
它运作良好,但在发布第一条新闻后出现了问题。当我再次发布新闻时,返回后键盘仍然在屏幕上。
我在这里看到了一些与此相似的问题,但它们没有用。
我尝试对所有 webViews、textFields 和 textViews 进行 resignFirstRersponder 。另外我\我尝试实现方法disablesAutomaticKeyboardDismissal,但它对我没有帮助。
我不知道在哪里寻找问题......
所以问题是:为什么会发生这种情况?我该如何解决这个问题? fnd 如何获取有关键盘的一些信息? (它是否可见,什么对象有焦点等,任何可能有助于解决问题的东西)
还有一件事。我有类似的 iPhone 应用程序,它似乎工作正常。
I have a problem with my iPad app.
I perform authorization in social networks (facebook, twitter etc.) to post information from app. Several webviews change each other (login, content of post, captcha). They have text fields and I have to show keyboard. After posting I return to some start view with posted information.
It works good, but after posting first news something goes wrong. When I post news one more time, after return keyboard is still on the screen.
I saw here some questions familiar to this, but they wasn't useful.
I tried to make resignFirstRersponder to all webViews, textFields and textViews. Also i\I tried to implement method disablesAutomaticKeyboardDismissal but it doesn't help me.
I don't know where search for problem...
So questions are: why could this happened? How can I solve this? fnd How can I get some information about keyboard? (is it visible, what object has focus etc., anything that could be useful to solve problem)
And one more thing. I have similar app for iPhone and it seems to work correct.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
试试这个:
确保将 searchBar 替换为您案例中实际第一响应者的对象
Try this:
Make sure to replace searchBar with the object that is the actual First responder in your case
问题终于解决了。原因是我改变了可见视图的方式。我为 ViewController 的 view 属性设置了一个新值。由于先前的视图包含焦点所在的文本字段,因此在更改视图之前焦点并未丢失(并且键盘仍在屏幕上),但我丢失了先前视图的处理程序。
解决方案是:在更改视图之前将FirstResponder 重新分配给所有(或当前)输入。
希望,很清楚。感谢您的帮助!
Problem is fixed, finally. The reason was the way I had changed visible view. I set a new value to view property of ViewController. And as previous view contains text field with focus on it, focus wasn't lost before changing view (and keyboard was still on the screen), but I had lost handler to previous view.
Solution is: resignFirstResponder to all (or current) inputs BEFORE changing view.
Hope, it's clear. Thanks for your help!