Re: NSView autoresizing
Re: NSView autoresizing
- Subject: Re: NSView autoresizing
- From: Andy Lee <email@hidden>
- Date: Tue, 3 Apr 2007 17:56:39 -0400
On Apr 3, 2007, at 5:04 PM, Cathy Shive wrote:
The view stays centered until i
resize the window smaller than the view. Then, when I expand the
window again, the view becomes stuck to one of the window's sides. If
I repeat this action over and over, the view will unstick and stick to
different sides of the window.
It's a limitation of springs and struts as a way of specifying resize
behavior. In your case, the superview scales the gaps around the
subview to preserve their relative proportions. When your view hit
the edge of the window (or, more precisely, the edge of its
containing view, which was the content view of the window), its
distance from that edge became zero. Thereafter, all scaling of that
gap continued to return zero, so the subview stuck to that edge.
AFAIK the only way around this is to either give the window a minimum
size that prevents the problem, or code your own workaround, as you did.
When I ran into the problem with *two* subviews of a superview that
were getting mushed together, I wrote a custom view class to use as
the superview. My custom view remembers the margins around and
between its subviews, in its -awakeFromNib method. If you think this
might be useful, it's in the source for AppKiDo (easy to Google) and
it's called DIGSMarginView. It's not intended to be general-purpose
-- it was just for my one particular need -- but anyway, you're
welcome to it.
--Andy
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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