• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Bottom-edge constraint not enforced in IB but is in runtime?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

References: 
 >Re: Re: Bottom-edge constraint not enforced in IB but is in runtime? (From: Marc Respass <email@hidden>)
 >Re: Bottom-edge constraint not enforced in IB but is in runtime? (From: Rick Mann <email@hidden>)
 >Re: Bottom-edge constraint not enforced in IB but is in runtime? (From: Kevin Cathey <email@hidden>)

  • Prev by Date: Re: "Capturing 'self' strongly in this block is likely to lead to a retain cycle"
  • Next by Date: Re: cocoabuilder closed?
  • Previous by thread: Re: Bottom-edge constraint not enforced in IB but is in runtime?
  • Next by thread: One more try - NSCollectionView multi-selection problem..
  • Index(es):
    • Date
    • Thread