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: Kyle Sluder <email@hidden>
- Date: Tue, 20 Mar 2012 12:26:21 -0700
On Mar 20, 2012, at 11:46 AM, Charles Srstka wrote:
> On Mar 20, 2012, at 1:21 PM, Kyle Sluder wrote:
>
>> It ran the constraints system, solved for the maximum size of the content view, and prevented you from resizing the NSWindow. But it knew what all the subviews were: the empty set. That's not the same as solving the constraints system without regard to subviews.
>
> Sure it is. The developers of the NSWindow object had no idea what views I was going to put into it, so they coded it to dynamically determine its min and max size based on what views it contains at runtime. I’d like to do the same thing with my view class.
NSWindow runs the constraint system on its view hierarchy, and then constrains the size of the window the size computer for its content view.
>
> Running the constraints system, solving for the maximum size of the content view, and preventing the view from being resized any larger than that is *precisely* what I’d like to do. Is there any way to do this (short of iterating through the constraints and doing the math manually, which is not likely to be future-proof given that Apple could add new constraint types in the future that my view would’t know about)?
The formulation of your question led me to believe you wanted to run the constraints system on a view without care for the subviews it contained. Of course NSWindow doesn't know what's contained within its contentView; including that bit in your question is a bit misleading.
Does calling -layoutSubtreeIfNeeded not do what you want?
--Kyle Sluder
_______________________________________________
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