Constraints, Scrollviews, and Custom Views

I recently have been trying to deal with NSScrollViews wrt embedding a view from a XIB in the scrollview and get it to work. As I was unsuccessful, and no web search got me to complete success, I created a simpler project,

ScrollTestProg (on github)

that binds a manually created view into a scrollpane. Much of the info comes from blog by B J Homer, but even that didn’t get me to the promised land without a lot of additional experimentation.

There probably is some cruft that doesn’t need to be there, but the main bit to look at is in the constructor for MyView.swift.

Like B J Homer says, the Using Scroll Views with Auto Layout documentation on this apparently is for iOS and is misleading AND DOESN’T WORK for MacOS.

Next I’m going to attempt to add a view contained in a XIB file as the contents of the scrollview. The ultimate goal is for the scrollview to contain views set up via a SplitViewController with any number of split views.

UPDATE 5/14/17

I added A Scrolling SplitViewController-controlled view project on github I think pretty much does the job. I don’t understand why the split views don’t expand to fill the space vertically, but when you add more split views (with Ctl-Cmd-A) things work properly.

It’s pretty straightforward really. What got me on the wrong track was trying to use NSView’s replaceSubview(), trying to replace the clipview’s subview. That for some reason is a rat-hole.

Leave a Reply

Your email address will not be published. Required fields are marked *