从导航堆栈中弹出视图时,为什么键盘不显示?

发布于 2024-12-15 21:35:39 字数 326 浏览 2 评论 0原文

我的视图上有几个 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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

赴月观长安 2024-12-22 21:35:39

我已经弄清楚了,据我所知,这是苹果代码的一个错误。我在 UITextField 的一个父视图上有一个名为 firstResponder 的属性。似乎没有任何理由为什么我不应该使用这个名称,但显然苹果已经在他们的代码中的某个地方使用了它,当我使用这个名称创建一个属性时,它会导致框架中的第一响应者代码严重出问题了。解决方案是将我的财产命名为其他名称。

辞职第一响应者使事情正常进行的唯一原因是我还将firstResponder 属性设置为nil。

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.

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

我们的影子 2024-12-22 21:35:39

我想键盘是被第一响应者辞职之外的其他机制隐藏的,所以系统认为它已经在显示键盘,所以不需要再次显示它。

如果您可以获得一个具有可重现实现的简单示例应用程序,那么这听起来像是 iOS 中的一个错误,您应该向 Apple 报告。

I imagine the keyboard is being hidden by some other mechanism than first responder resigning, so the system thinks it is displaying the keyboard already, and so does not feel the need to show it again.

If you can get a simple example app with a reproducible implementation, it sounds like a bug in iOS which you should report to Apple.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文