在 UITextView 委托事件之前调用的键盘事件 [英] Keyboard events called before UITextView delegate events
问题描述
我有一个 UITableView
和 UITextViews
和 UITextFields
在它的单元格上.很明显,键盘与较低的单元格重叠,您看不到正在输入的内容.所以我想滚动 tableview
以使该字段可见.我编写了 iOS
文档推荐的代码:https://developer.apple.com/library/ios/documentation/StringsTextFonts/Conceptual/TextAndWebiPhoneOS/KeyboardManagement/KeyboardManagement.html
I have a UITableView
with UITextViews
and UITextFields
on it's cells. As obvious the keyboard overlaps the lower cells and you cannot see what you are typing.
So I want to scroll the tableview
to get the field visible.
I wrote the code the iOS
docs recommended: https://developer.apple.com/library/ios/documentation/StringsTextFonts/Conceptual/TextAndWebiPhoneOS/KeyboardManagement/KeyboardManagement.html
BUT 键盘事件回调 keyboardWillShow:
被调用 before UITextView
编辑回调 textViewDidBeginEditing:代码>.因此,当我尝试计算使活动文本视图可见所需的滚动时,我无法设置活动文本视图.
BUT the keyboard event callback keyboardWillShow:
is called before the UITextView
edit callback textViewDidBeginEditing:
. So I cannot set the active textview when I try to calculate the scrolling I need to make the active textview visible.
有人知道解决这个问题的方法吗?
Anyone knows a solution for this?
推荐答案
从keyboardWillShow:
中取出代码,加入到keyboardDidShow:
中,这显然是在它之后调用的已经呈现...
Take the code out of keyboardWillShow:
and add it into keyboardDidShow:
This is obviously called after it has been presented ...
如果您使用通知,则需要添加:
If you're using notifications you need to add:
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardDidShow:) name:UIKeyboardDidShowNotification object:nil];
这篇关于在 UITextView 委托事件之前调用的键盘事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!