Get currently typed word in a UITextView

前端 未结 5 1219
谎友^
谎友^ 2020-12-19 23:19

I want to get the currently typed word in a UITextView. A way to get a completely typed word can be found here UITEXTVIEW: Get the recent word typed in uitextvi

5条回答
  •  失恋的感觉
    2020-12-20 00:04

    Your range parameter from the - (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text delegate method points at the exact place you change the UITextView string value.

    The location property of the structure points to the changing string index, that's simple. The length not usually equals to text.length, be careful, user may select characters from the string to replace it with another string.

提交回复
热议问题