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 (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to