问题描述
我在模态表格(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.
(参见)
这篇关于UITextField的键盘不会被忽略。不完全是的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!