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 something that I am coding.

I declare NSScrollView as an IBOutlet, add it as a property, and then synthesize it. However, this is unsuccessful.

The scroll bar appears when you resize, but at the moment they do not perform any functions.

I tried using the documentation for the apple, but then again, there is no joy.

Any help? Thanks!

+4
source share
1 answer

As you said: "For my purposes, any container that scrolls will do the trick." You can use NSTextView in NSScrollView . And to set the text you need to use setString instead of setStringValue.

An example of how to set text in an NSTextView :

.h

 IBOutlet NSTextView *textView; 

wow

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


Remember to IBOutlet NSTextView not NSScrollView .

NSTextView is in NSScrollView :

enter image description here

+14
source

Source: https://habr.com/ru/post/1401107/


All Articles