Reputation: 381
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?
Upvotes: 0
Views: 1739
Reputation: 1379
In Swift one can do
textView.scroll(NSPoint.zero)
where one loads content
Upvotes: 0
Reputation: 722
Try with this method
[textview scrollToBeginningOfDocument:self];
or
//NSTextView inside an NSScrollView you can create object for that scrollview
[scrollView.contentView scrollToPoint:NSMakePoint(0, scrollView.documentView.frame.size.height-scrollView.contentSize.height)];
Upvotes: 1
Reputation: 4282
If you insert a NSTextView with Interface Builder, it will actually reside inside of NSScrollView. Interface Builder automatically do this.
I mean, this is normal scroll view behavior and you can do 'scroll to top' as usually.
Upvotes: 0