I have implemented a custom NSView
which contains many NSTextField
s and other NSView
s. I then embedded that custom view in a scroll vi
The NSScrollView needs to have an X, Y, width and height constraint so that it keeps it's frame the same even if you have views in NSClipView that have bigger width/height that the ScrollView.
I have seen that if you have views with bigger dimensions and you don't have these constraints, the NSScrollView's frame is automatically set to be the same as the NSClipView, which would be a bigger frame and it may exceed the size of the Window's Frame.
That is why sometimes it might appear that the NSScrollView doesn't scroll, but it is actually big enough that it contains all the views, exceeding the Window's frame, and it does not need to scroll.
I made it work by doing this :
Set the following constraints for NSScrollView
As seen below
Do the same for every View in NSClipView
The Views will also keep their sizes after you change the frame size of the NSScrollView
, if you want to do that.
In my case it worked like charm! I have an ImageView
inside the NSClipView
and it scrolls after you resize the window as well. Hope it works!