我是 iOS 开发新手。
我的头文件是这样写的
@interface TextView : UITextView <UITextViewDelegate, UIPopoverControllerDelegate>
在 TextView.h 中。
实现文件代码如下:
- (BOOL)textViewShouldBeginEditing:(TextView *)textView
{
ZWLog(@"called should begin edit");
return YES;
}
- (void)textViewDidBeginEditing:(TextView *)textView
{
ZWLog(@"called did begin edit");
}
- (BOOL)textViewShouldEndEditing:(TextView *)textView
{
ZWLog(@"called should end editing");
return YES;
}
- (void)textViewDidEndEditing:(TextView *)textView
{
ZWLog(@"view did end edit");
return YES;
}
- (BOOL)textView:(TextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text
{
//my own code
return YES;
}
- (void)textViewDidChange:(TextView *)textView
{
//my own code
}
当我开始在 UITextView
中输入一个字符时,我收到了来自
textViewShouldBeginEditing
。textViewDidBeginEditing
。shouldChangeTextInRange
。textViewDidChange
。
但我没有从 textViewDidEndEditing
或 textViewShouldEndEditing
得到任何回应。您知道为什么这些没有被调用吗?
感谢您的回答。
最佳答案
textViewDidEndEditing 在文本字段退出其第一响应者时调用,当键盘消失时。
关于iphone - 不调用 textViewDidEndEditing,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18607599/