Question

Coming from an iOS background, I presumed that NSScrollView would work out of the box, and I presumed that contentSize would reflect the size of the documentView passed to it. This is not the case, if the NSScrollView is created programmatically.

First issue was: why does contentSize not update when a document view is passed in.

Second issue was: why can I not scroll the scroll view, despite the fact there was more content.

Was it helpful?

Solution

The answer to the first question appears to be: don't look at contentSize, look instead at [[scrollView contentView] documentRect].

The answer to the second is that you have to explicitly set hasVerticalScroller and/or hasHorizontalScroller. The scroll view will then dynamically create NSScroller views.

You can also use setAutohidesScrollers:YES to make those appear only when necessary.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top