在 UITextView 委托事件之前调用的键盘事件

6ro*_*od9 3 uitableview uiscrollview uitextfield uitextview ios

我有一个UITableView带有它的细胞UITextViewsUITextFields很明显,键盘与下部单元格重叠,您看不到正在输入的内容。所以我想滚动tableview以使该字段可见。我编写了文档推荐的代码iOShttps://developer.apple.com/library/ios/documentation/StringsTextFonts/Conceptual/TextAndWebiPhoneOS/KeyboardManagement/KeyboardManagement.html

键盘事件回调keyboardWillShow:是在编辑回调之前调用的。因此,当我尝试计算使活动文本视图可见所需的滚动时,我无法设置活动文本视图。UITextViewtextViewDidBeginEditing:

有人知道这个问题的解决方案吗?

CW0*_*007 5

将代码取出keyboardWillShow:并添加到keyboardDidShow:这显然是在呈现后调用的......

如果您使用通知,则需要添加:

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardDidShow:) name:UIKeyboardDidShowNotification object:nil];
Run Code Online (Sandbox Code Playgroud)