Re: How to get max size of view according to constraints?
Re: How to get max size of view according to constraints?
- Subject: Re: How to get max size of view according to constraints?
- From: Per Bull Holmen <email@hidden>
- Date: Wed, 21 Mar 2012 14:54:44 +0100
Den 01:13 21. mars 2012 skrev Charles Srstka
<email@hidden> følgende:
> On Mar 20, 2012, at 7:00 PM, Peter Ammon wrote:
>
>> 2. Establish another constraint that says the height of the document view equals the height of the scroll view. Give this constraint a priority lower than required. What its priority should be depends on how tightly you want the document view to fill the scroll view, i.e. which other constraints it should be allowed to break.
>
> This sounds great in concept, but the height I want (if the constraints will allow it) is the scroll view’s documentVisibleRect, not its frame, since the latter includes the size of the scroll bars if they’re visible, and I don’t think that’s doable directly via constraints. However, watching the scroll view’s NSViewFrameDidChangeNotification and manually adding non-required constraints to the size I get from -documentVisibleRect (and clearing out those constraints the next time) works like a champ. As you point out, the mistake I was making before was calling setFrame: here instead of doing this via constraints. Thanks!
I am old school and know nothing about constraints, but given your
descriptions, perhaps you can tie the document view size to the clip
view size (which is also called content view) instead of the scroll
view size?
Per
_______________________________________________
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