Predictive input iOS8 calls the following delegate method of UITextView several times, as a result of which the selected word is inserted several times into the view.
This code works to enter single letters and copy / paste, but not when using the predictive input panel; why not?
- (BOOL) textView:(UITextView*)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString*)text { textView.text = [textView.text stringByReplacingCharactersInRange:range withString:text]; return false; }
Using this code; if I enter an empty UITextView and tap "The" in the predictive text view (auto-complete), it inserts "The" into the view by three calls to this method. Parameters passed for each call:
- range:
{0,0} text: @"The" - range:
{0,0} text: @"The" - range:
{3,0} text: @" "
The space that I can understand; but why insert "The" twice?
objective-c ios8 uitextview
Wex
source share