Problem creating views with scrolling

Discussion in 'Mac Programming' started by lpetrich, Jan 1, 2017.

  1. lpetrich macrumors member

    Nov 26, 2009
    For the last few hours, I have been attempting to embed a NSBox in a NSScrollView, so that the box will be partially displayed with scrollbars for scrolling through it if it is too large for the window.

    I do the recommended procedure of creating a box, selecting it, then doing Editor > Embed In > Scroll View.

    I then constrain the scroll view to be the same size as the window, so that when the window is resized, the scroll view is also. That works, but the problem is with the box.

    I've been unable to pin the box's upper left corner to the view's upper left corner, while keeping the box's size fixed. In fact, I want to change the box's size programmatically for the content that I want for it -- content that I intend to place programmatically.

    Is there any way to get my desired behavior by using some suitable combination of constraints created in Xcode's nib/xib editor? Or will I have to do it programmatically?
  2. lpetrich thread starter macrumors member

    Nov 26, 2009
    After some hours of trying to do it with Xcode's GUI-layout editor (formerly the Interface Builder), I decided to do it programmatically and use some of Apple's sample code as a guide.

    This code resides in a NSWindowController subclass and the content is Bkgd.

Share This Page