Question

How can I make programmatically an NSTextView scroll to the cursor position?

Était-ce utile?

La solution

This should work

NSUInteger cursorPosition;
cursorPosition = [[[self.textView selectedRanges] firstObject] rangeValue].location;
[self.textView scrollRangeToVisible:NSMakeRange(cursorPosition, 0)];
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top