【发布时间】:2013-09-07 14:12:43
【问题描述】:
我是 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 的任何回复。你知道为什么这些没有被调用吗?
感谢您的回答。
【问题讨论】:
-
当 KeyBoard 消失时调用 textViewDidEndEditing 方法,换句话说,当用户停止在 textview 中输入并调用 resignfirstresponder 时。
-
@GyanendraSingh:感谢您的评论。
标签: iphone ios uitextview uitextviewdelegate