NSScrollView autolayout (10.10)
NSScrollView autolayout (10.10)
- Subject: NSScrollView autolayout (10.10)
- From: Roland King <email@hidden>
- Date: Wed, 07 Jan 2015 20:26:52 +0800
I want an NSStackView which can be scrolled. I dragged an NSScrollView out in IB, that gives me a scrollview, the scrollers, a clip view and a child NSView of the clip view, which IB doesn’t want you to delete. I dragged my NSStackView out and made it a child of that view
+- NSScrollview
+- NSClipView
+- NSView
+- NSStackView
There were no constraints set up initially between anything and anything else. After a large amount of messing about I constrained the NSStackView to all 4 sides of its parent, non-deletable NSView. I then constrained that NSView top, left and right (but not bottom) to its parent, the ClipView. This almost worked, except the StackView grew from the bottom up, not the top down, so I subclassed NSClipView to return YES for isFlipped.
This appears to actually work but I don’t entirely understand every piece of why. I think I understand why the NSView ends up being the intrinsic content size of the StackView, which is what I want, and why the clipview is allowed to be independent of that piece of content (only pinned on three sides). But I don’t understand what’s driving the contentSize of the scrollview for me.
More generally, is this how you’re supposed to set up a view which has intrinsic content size inside a scroll view in IB, pin that view to the NSView IB gives you, then pin that to the clipview on 3 sides only and flip the clip (why?).
I did try changing the class of the NSView I can’t delete to NSStackView and avoid the middle man, very bad things happened, constraints were generated in constraint language which didn’t parse, so I decided to put it back where it was.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden