Question

I have an NSScrollView that needs to display a variable amount of NSViews in it. I made a custom NSView that has isFlipped return YES and put my NSViews in that before I set it to be the NSScrollView's documentView. That works well. It displays my items top to bottom like I would expect.

But, when the contents changes and I need to change the NSScrollView's documentView's frame, my contents disappears.

This would be WAY easier with a UIScrollView, but alas.

I'm assuming these are equivalent:

[NSScrollView.documentView setFrame:newFrame];
[UIScrollView setContentSize:newSize];

I would imagine that a lot of coders need to have a flipped NSScrollView, but how do you deal with changing the content size without this madness? Obviously, I'm missing something.

Anyone? Thanks!

Was it helpful?

Solution 2

The problem was with the internal views and autoresizing/constraints. My internal views are actually a series of view controllers with their own xib file. In each view controller, I added the following line:

[self.view setAutoresizingMask:NSViewNotSizable];

And that solved everything.

Special thanks to lead_the_zeppelin for helping me (in chat) go through everything.

OTHER TIPS

can you try just setting

[scrollView.documentView setFrameSize:newFrame.size];

to see if your content disappears?

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