My UITextView delegate registers a carriage position using the following:
- (void)textViewDidBeginEditing:(UITextView *)textView { CGPoint cursorPosition = [textView caretRectForPosition:textView.selectedTextRange.start].origin; NSLog(@"cursor: %@", NSStringFromCGPoint(cursorPosition)); }
But the stated position is always inaccurate. In particular, it reports the previous cursor position - for example, if I click once inside the text view at position (x, y), then outside, and then back inside (x2, y2), the second click (x, y) coordinates are registered .
In fact, the selected TextRange is a problem - the previous range is reported.
What am I missing? I do not see another delegate method that I can use instead.
source share