Kevin
Kevin

Reputation: 1479

NSScrollView in Cocoa

I am trying to get an NSSrollView with an NSTextField in it to work, however the scrollbars do not seem to respond to anything that I am coding.

I am declaring the NSScrollView as an IBOutlet, add it as a property and then synthesizing it. However, it's to no avail.

The scrollbars do appear when I resize, however they serve no function at the moment.

I have tried to use the apple documentation, but again, no joy there.

Any help? Thanks!

Upvotes: 4

Views: 7070

Answers (1)

Justin Boo
Justin Boo

Reputation: 10198

As You was saying "For my purposes, any container which scrolls will do the trick" You can use NSTextView in an NSScrollView. And for setting text You need to use setString instead setStringValue.

Example how to set text in NSTextView:

.h

IBOutlet NSTextView *textView; 

.m

-(void)awakeFromNib {
    NSString *string = @"my text";
    [textView setString:string];
}


Don't forget IBOutlet NSTextView not NSScrollView.

NSTextView is in NSScrollView:

enter image description here

Upvotes: 14

Related Questions