• 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: Custom layout and constraints
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Custom layout and constraints


  • Subject: Re: Custom layout and constraints
  • From: Kyle Sluder <email@hidden>
  • Date: Sun, 21 Sep 2014 07:44:57 -0700

On Sep 21, 2014, at 7:10 AM, Allan Odgaard <email@hidden> wrote:
>
>
> That is, if the view has hugging and/or intrinsic content size then the size from the derived constraints will be used, otherwise `NSZeroSize`. Likewise the origin will be `NSZeroPoint` unless constrains are added to affect the position.
>
> So how can I ensure the position I set for a subview’s frame in my `layout` override is not (implicitly) changed later?

You need to turn on translatesAutoresizingMaskIntoConstraints for the subviews you position manually. That way Auto Layout knows how to position them.

I really view this as a bug. If a view has no constraints applied to it, the view should not be touched by Auto Layout at all. That was the implicit promise made to us by saying we could still perform manual layout in -layout. Breaking that promise has led to bugs where existing code that used -setFrame: would fail because it was handed a view that had translatesAutoresizingMask turned off at some point. It also means that any -setFrame:-based code triggers a recursive pass through the entire view hierarchy, which is exactly what you don’t want in any animation code that’s using -setFrame:.

You’re the third person on this mailing list in the past month to be bitten by this surprising behavior. I would suggest you file a Radar.

--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


  • Follow-Ups:
    • Re: Custom layout and constraints
      • From: Allan Odgaard <email@hidden>
References: 
 >Custom layout and constraints (From: Allan Odgaard <email@hidden>)

  • Prev by Date: Custom layout and constraints
  • Next by Date: Re: return string that is the difference between two other strings
  • Previous by thread: Custom layout and constraints
  • Next by thread: Re: Custom layout and constraints
  • Index(es):
    • Date
    • Thread