I really need some suggestion, I need to stop uitextview by jumping to the last line after entering some text programmatically, I read the same question in here , here , here , and. I tried all the answers in each question, but my uitextview still always jumps to the last line after pasting the text, I can move the cursor back to the last position, but I can not stop it from jumping, and it makes me dizzy when I use my application in a simulator or device. Can someone give me another key?
this is the code i made for this case, i will implement this in the delegate method textviewDidChange:
NSString *textAdd = @"adding text";
NSRange *range = self.codeTextView.selectedRange;
[textview setScrollEnabled:NO];
textview.userInteractionEnabled = NO;
textview.text = [textview.text stringByReplacingCharactersInRange:range withString:[NSString stringWithFormat:@"%@", textAdd]];
textView.userInteractionEnabled = YES;
[textView becomeFirstResponder];
textView.selectedRange = NSMakeRange(range+[textadd length], 0);