I ran into a problem when iOS gives incorrect UITextViewDelegate information when the delete key is held on the keyboard.
When a HOLDS user deletes a key in a UITextView on an iPad, a UITextView will begin to delete whole words instead of single characters, the longer it is held (note: this does not happen in the simulator).
When this happens, the UITextView delegation method:
- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text
Gets a call with a range consisting of the correct cursor location, but with a length of 1. This is not true since UITextView now removes whole words, not single letters. The following code, for example, will print only one space.
[textView substringWithRange:range] string contains " "
Although UITextView removes the whole word. Replaceable text is correctly set as an empty string. Does anyone know of a solution or workaround for this problem?
source share