Re: Custom layout and constraints
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