Re: Auto layout and scroll views on OS X
Re: Auto layout and scroll views on OS X
- Subject: Re: Auto layout and scroll views on OS X
- From: Keary Suska <email@hidden>
- Date: Tue, 22 Jul 2014 08:13:52 -0600
On Jul 22, 2014, at 5:02 AM, Allison Newman <email@hidden> wrote:
> I have a simple application (zipped project can be found here: http://phonicnoise.com/UIsandbox.zip ) that generates two rows of square buttons. The number of buttons is generated dynamically based on model data. The buttons plus spacing should take up the entire vertical space of their parent view, and the width adjusts accordingly (as buttons need to remain square, if you increase their height, the width has to increase as well).
>
> Anyway, the application works just fine if I add the content directly into a window - resizing the window resizes the buttons. But if I try to create a scrollview that takes up all of the window, and then place the content in the scroll view, nothing is drawn. Instead I get the following error message:
>
> 2014-07-21 12:29:33.382 UI sandbox[14370:2640458] Failed to set (contentViewController) user defined inspected property on (NSWindow): Unable to install constraint on view. Does the constraint reference something from outside the subtree of the view? That's illegal. constraint:<NSLayoutConstraint:0x6080000832f0 V:|-(0)-[NSView:0x608000120d20] (Names: '|':NSClipView:0x1002077f0 )> view:<NSView: 0x608000120d20>
>
> I have read the Auto layout programming guide,, and in particular the section concerning scrollviews, and I also looked up this tech note (https://developer.apple.com/library/ios/technotes/tn2154/_index.html) but neither really shed much light on the problem for me, and I didn’t find anything useful searching back through the history of cocoadev…
>
> In the project code, I have a define that can be activated to switch between the scrollview / no scrollview configurations: PN_USING_SCROLLVIEW.
>
> If anyone can point me in the right direction for sorting this out, that would be much appreciated!
Based on the error it looks like a Mac OS X project, but if not, please always specify because there isn't complete feature parity with iOS. So, for Mac OS X, auto layout is broken for NSScrollViews. Perhaps this will change in 10.10.
The only advice I have found, which I have not yet been able to utilize successfully but might still be useful advice:
http://www.cocoabuilder.com/archive/cocoa/326783-guidelines-for-using-autolayout-with-nsscrollview.html
http://www.cocoabuilder.com/archive/cocoa/326788-ambiguous-layout-for-documentview-in-nsscrollview.html
HTH,
Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"
_______________________________________________
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