سؤال

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