Re: Bottom-edge constraint not enforced in IB but is in runtime?
Re: Bottom-edge constraint not enforced in IB but is in runtime?
- Subject: Re: Bottom-edge constraint not enforced in IB but is in runtime?
- From: Kyle Sluder <email@hidden>
- Date: Tue, 10 Jul 2012 11:25:43 -0700
On Tue, Jul 10, 2012, at 08:01 AM, Kevin Cathey wrote:
> The default value of translatesAutoresizingMaskIntoConstraints for top
> level views in IB is YES on both Lion and Mountain Lion. But this can be
> disabled using the Attributes Inspector and uncheck "Translates Mask Into
> Constraints"
Unfortunately this is not the complete truth. It is also YES for
document views of NSScrollViews, and cannot be disabled even in the
latest versions of Xcode that I have tried. I have a view that manages
its relationship to its enclosing clip view using constraints, and I
obviously need to disable translatesAutoresizingMaskIntoConstraints for
this to work properly.
And because of the way that nib unarchiving works,
-setTranslatesAutoresizingMaskIntoConstraints: is called *after*
-initWithFrame:/-initWithCoder:. So the solution I've been using is to
override -updateConstraints to call [self
setTranslatesAutoresizingMaskIntoConstraints:NO] before calling super.
I suppose I could instead override
-translatesAutoresizingMaskIntoConstraints like so:
- (BOOL)translatesAutoresizingMaskIntoConstraints {
if ([self superview] == [[self enclosingScrollView] contentView])
return NO;
else
return [super translatesAutoresizingMaskIntoConstraints];
}
...but it's not documented whether the constraint system calls
-translatesAutoresizingMaskIntoConstraints, or uses an internal flag to
represent that state.
Also, IB doesn't let you edit the autoresizing mask of a view in a nib
with autolayout turned on, even if that view is a top-level view and
should have translatesAutoresizingMaskIntoConstraints=YES because it's
going to be installed in a view hierarchy you don't control. This is
also incredibly unhelpful.
--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