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 11:03:36 -0700
On Tue, Mar 20, 2012, at 12:01 PM, Charles Srstka wrote:
> Right, but the problem is that I want to make a view that can be given
> arbitrary subviews at runtime, and I don’t necessarily know what its
> subviews and their constraints will be at compile time. What I want is a
> way to determine the range of sizes that this view can have, at runtime.
This is precisely the problem that the constraint system solves. You
can't figure it out without actually solving all constraints.
> I can find the minimum size via -fittingSize, but I can’t figure out how
> to get the maximum size.
>
> Specifically, what I’m trying to do is to make a constraints-aware
> NSScrollView. You can put whatever views you want in it, and it resizes
> its document view as appropriate as you resize the NSScrollView (say, by
> resizing the window it’s in). The idea is, it should attempt to resize
> the document view to match the size of the scroll view. If the user tries
> to resize the view smaller than what the constraints will allow, then the
> scroll bars appear. That part is working, but if the user tries to make
> the scroll view too big, then everything blows up when my code attempts
> to stretch the document view out.
Tried it. I don't believe it's possible. The whole point of scroll views
(actually, clip views) is that the bounds coordinate space inside them
is independent of the size of the view itself. If you start drawing
constraints between the contents of the scroll view and its enclosing
clip view, you are violating that principle. And it winds up being a
moot point because -[NSScrollView tile] just calls -setFrame: directly
on the clip view.
> What I’m trying to find is the upper limit on the width and height
> according to the current set of constraints at runtime, when I don’t
> necessarily know what the subviews or their constraints are.
I do not believe this question makes sense from the perspective of the
layout system.
--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