当从导航堆栈中弹出视图时,为什么键盘不显示? [英] Why does the keyboard not show when a view is popped from the navigation stack?

查看:70
本文介绍了当从导航堆栈中弹出视图时,为什么键盘不显示?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在视图上有几个UITextField对象.当我按下它们时,我也会得到一个键盘和UIKeyboardWillShowNotification事件.当我将一个新的视图控制器推入堆栈时,其中一个文本字段是第一个响应者,则键盘会动画(如我预期的那样).但是,当我再按后退"按钮时,它们的文本字段将成为第一响应者,但键盘不会弹出.当我在同一视图中单击另一个文本字段时,再次出现键盘故障.当我重新进入视图时,如果键盘没有弹起,那将是很好的选择,但是我不确定当我单击另一个文本字段时会导致键盘弹起的原因.为什么会发生这种情况,我该如何解决?

I have several UITextField objects on a view. When I press on them, I get a keyboard and the UIKeyboardWillShowNotification event as well. When I push a new view controller on to the stack while one of the text fields is the first responder, the keyboard animates away (as I expected). When I then press the back button, however, they text field becomes the first responder, but the keyboard doesn't come back up. When I click on a different text field in the same view, again, the keyboard fails to come up. It would be fine if the keyboard wasn't up when I reentered the view, but I'm not sure what would make it fail to come up when I click on another text field. Why does this happen, and how can I fix it?

旁注,当我离开屏幕前辞去第一响应者的权限时,一切正常.

Side note, when I resign first responder before leaving the screen, everything works fine.

推荐答案

我已经弄清楚了,据我所知,这是Apple代码的错误.我在名为firstResponder的UITextField的父视图之一上具有一个属性.似乎没有任何理由不应该使用该名称,但显然Apple已在其代码中的某个位置使用了该名称,当我使用该名称创建属性时,它会导致框架中的第一个响应者代码严重使用臭虫出来.解决的办法是给我的财产起个别的名字.

I have figured it out, and to the best of my understanding this IS a bug with Apple's code. I have a property on one of the parent views of the UITextField that is named firstResponder. There doesn't appear to be any reason why I shouldn't use this name but clearly Apple has already used it somewhere in their code, and when I create a property with this name, it causes the first responder code in the framework to seriously bug out. The solution is to name my property something else.

辞退第一响应者使工作正常的唯一原因是我还将firstResponder属性设置为nil.

The only reason resigning first responder was making things work was that I was also setting the firstResponder property to nil.

这篇关于当从导航堆栈中弹出视图时,为什么键盘不显示?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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