View Single Post
Mark FX

Mark FX's Avatar
Member Since: Aug 13, 2011
Location: West Sussex, UK
Posts: 180
Mark FX has a spectacular aura about

Mark FX is offline
You can put the multiline label in the scroll view, but I did restle a bit with it myself.

I placed a multiline label on a window from the object library, and also a scroll view from the object library, then I created two IBOutlet properties in my AppDelegate, one of a NSTextField called myMultilineLabel, and one of a NSScrollView class called myScrollView, then finally connect them in Interface Builder too the Label and Scroll View on the window.

next I sized the label too what it needed to be, to hold the text it was going to hold, then I selected the scroll view, and double clicked it's interior to select it's content view, then I resized the content view with the inspectors size tab, by entering the sizes to the labels size.

then in the AppDelegate's applicationDidBecomeActive: method, I entered the code below.

    NSString *myString = [[NSString alloc] initWithFormat:@"line 1\nLine 2\nLine 3\nLine 4\nLine 5\nLine 6\n"];
    [myMultiLabel setStringValue:myString];
    [myScrollView addSubview:myMultiLabel];
    [myScrollView setDocumentView:myMultiLabel];
A second way to achieve this is to select your multi label, and then from Xcode's editor menu, select Embed In > Scroll View.
But as of writing I did'nt get this method to work very well, but will let you know if I can.

Regards Mark
QUOTE Thanks