The method used at the beginning is the function textview: shouldchangetextinrange: replacementtext: To judge:
// When you type done, insert a line break and execute addbookmark <br/>-(bool) textview :( uitextview *) textview <br/> shouldchangetextinrange :( nsange) range <br/> replacementtext :( nsstring *) text <br/> {<br/> // you can specify the input character in the range, whether the limit is exceeded <br/> nsstring * STR = [nsstring stringwithformat: @ "% @", textview. text, text]; <br/> If (Str. length> bookmark_word_limit) <br/>{< br/> textview. TEXT = [textview. text substringtoindex: bookmark_word_limit]; <br/> return no; <br/>}< br/> return yes; <br/>}
However, it is found that this method cannot be used to judge the words entered by Lenovo when there is a Lenovo input, and then textviewdidchange: is used to verify the feasibility:
/* Due to Lenovo input, the function textview: shouldchangetextinrange: replacementtext: the number of words cannot be determined, <br/> Use textviewdidchange to determine the number of words in textview <br/> */<br/>-(void) textviewdidchange :( uitextview *) textview <br/>{< br/> // this judgment is used for Lenovo input <br/> If (textview. text. length> bookmark_word_limit) <br/>{< br/> textview. TEXT = [textview. text substringtoindex: bookmark_word_limit]; <br/>}< br/>}