我在视图中有一个文本字段和文本视图。我想在 textView 中编辑文本时在键盘上显示工具栏,但我不想在编辑 textField 时显示工具栏。我正在使用以下代码:
- (BOOL)textViewShouldBeginEditing:(UITextView *)textView
{
[super viewWillAppear:animated];
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
[nc addObserver:self selector:@selector(keyboardWillShow:)
name: UIKeyboardWillShowNotification object:nil];
[nc addObserver:self selector:@selector(keyboardWillHide:)
name: UIKeyboardWillHideNotification object:nil];
return YES;
}
和
- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField{
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillShowNotification
object:nil];
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillHideNotification
object:nil];
return YES;
}
我的问题是当用户尝试编辑文本字段并直接开始编辑 textView 时,我们无法为其显示工具栏?在这种情况下,如何在键盘上显示工具栏?