我有一个 UITableView
,单元格上有 UITextViews
和 UITextFields
。很明显,键盘与下方的单元格重叠,您看不到正在输入的内容。
所以我想滚动 tableview
以使该字段可见。
我编写了 iOS
文档推荐的代码:https://developer.apple.com/library/ios/documentation/StringsTextFonts/Conceptual/TextAndWebiPhoneOS/KeyboardManagement/KeyboardManagement.html
但是 键盘事件回调 keyboardWillShow:
在 UITextView
编辑回调 textViewDidBeginEditing 之前被调用:
。因此,当我尝试计算使事件 TextView 可见所需的滚动时,我无法设置事件 TextView 。
有人知道这个的解决方案吗?
最佳答案
将代码从keyboardWillShow:
中取出,加入到keyboardDidShow:
中,这显然是在它被呈现后调用的......
如果您使用的是通知,则需要添加:
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardDidShow:) name:UIKeyboardDidShowNotification object:nil];
关于ios - 在 UITextView 委托(delegate)事件之前调用的键盘事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22389114/