Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/94.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 如何知道在UITextView中何时输入字符?_Ios_Objective C_Character_Uitextview - Fatal编程技术网

Ios 如何知道在UITextView中何时输入字符?

Ios 如何知道在UITextView中何时输入字符?,ios,objective-c,character,uitextview,Ios,Objective C,Character,Uitextview,我正在做一个Objective-C项目。我希望在UITextView委托之后触发事件,shouldChangeTextInRange返回TRUE。但我似乎找不到。我想在UITextView中添加每个字符时更新其他变量 如果甚至没有可用的,如果光标移动到文本字符串的中间,点击退格或添加字符,我如何自定义shouldChangeTextInRange方法?当您在 - (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRa

我正在做一个Objective-C项目。我希望在UITextView委托之后触发事件,shouldChangeTextInRange返回TRUE。但我似乎找不到。我想在UITextView中添加每个字符时更新其他变量


如果甚至没有可用的,如果光标移动到文本字符串的中间,点击退格或添加字符,我如何自定义shouldChangeTextInRange方法?

当您在

- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text
UITextView
文本将替换为新文本

如果您想在
delegate
函数中返回
TRUE
之前了解
UITextView
中包含的文本,可以使用
NSString
中的以下方法获取该文本。确保使用
UITextView

NSString * strText = [textView.text stringByReplacingCharactersInRange:range withString:text];

请阅读-总结是,这不是一个理想的方式来解决志愿者,可能会适得其反获得答案。请不要将此添加到您的问题中。请对我的问题进行投票。我已经编辑过了。