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

有帮助吗?

解决方案

This should work

NSUInteger cursorPosition;
cursorPosition = [[[self.textView selectedRanges] firstObject] rangeValue].location;
[self.textView scrollRangeToVisible:NSMakeRange(cursorPosition, 0)];
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top