XtremeHek3r XtremeHek3r - 1 year ago 56
Objective-C Question

NSTextView always scrolls to bottom. How do I force it to display at the top?

I have an NSTextView in my XIB UI. In my code, I do

[textview insertText:@"text i put here"];

many times, and then finally

[textview setEditable:NO];

BTW, this is to create an information panel for my app.

When I run my app though, the text view always scrolls to the bottom. Is there any way to make it start at the top?

Answer Source

Try with this method

[textview scrollToBeginningOfDocument:self];


//NSTextView inside an NSScrollView you can create object for that scrollview

[scrollView.contentView scrollToPoint:NSMakePoint(0, scrollView.documentView.frame.size.height-scrollView.contentSize.height)];