UITextField的键盘不会被忽略。不完全是

编程入门 行业动态 更新时间:2024-10-25 00:29:31
本文介绍了UITextField的键盘不会被忽略。不完全是的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我在模态表格(iPad)中有一个表格视图,其中一个单元格包含一个UITextField。我的视图控制器持有对文本字段的引用,也是它的委托。

I have a table view in a modal form sheet (iPad), and one of the cells contains a UITextField. My view controller holds a reference to the text field and is also its delegate.

当文本字段命中Return时,我告诉它 -resignFirstResponder 里面的 -textFieldShouldReturn:。在另一种情况下,我想强制它结束编辑,所以我告诉整个表视图 -endEditing:YES 。然后我释放我对文本字段的本地引用,并重新加载行以用其他东西替换它。

When the text field hits Return, I tell it to -resignFirstResponder inside of -textFieldShouldReturn:. In another case, I want to force it to end editing, so I tell the whole table view to -endEditing:YES. Afterwards I release my local reference to the text field, and reload the row to replace it with something else.

在任何一种情况下键盘都不会消失。我不知道出了什么问题,我不确定如何进一步调试。我从来没有遇到任何其他文字编辑的粘性键盘问题 - 第一个响应者辞职总是表现得如预期。

The keyboard won't go away in either case. I don't know what's wrong, and I'm not sure how to debug further. I've never had a sticky keyboard problem with any other text editing I've done-- the firstResponder resignation has always behaved as expected.

有什么想法吗?谢谢。

推荐答案

实施 -disablesAutomaticKeyboardDismissal 并返回NO。 确实在iOS 6上运行,但您必须在正确的控制器中实现它。如果你有一个带有文本字段的子控制器的模态表单导航控制器,那就是需要方法实现的导航控制器,而不是子控件。

Implement -disablesAutomaticKeyboardDismissal and return NO. It does work on iOS 6, but you have to implement it in the right controller. If you have a modal form sheet navigation controller with a child controller that has text fields, it's the navigation controller that needs the method implementation, not the child.

(参见在IPAD上关闭键盘)

更多推荐

UITextField的键盘不会被忽略。不完全是

本文发布于:2023-11-27 08:52:41,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1637371.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:不完全   键盘   UITextField

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!