Re: Quickie about constraints
Re: Quickie about constraints
- Subject: Re: Quickie about constraints
- From: Charles Srstka <email@hidden>
- Date: Sat, 16 Aug 2014 02:45:28 -0500
On Aug 16, 2014, at 1:10 AM, Kyle Sluder <email@hidden> wrote:
> On Aug 15, 2014, at 8:44 PM, Ben Kennedy <email@hidden> wrote:
>>
>>> On 15 Aug 2014, at 8:17 pm, Graham Cox <email@hidden> wrote:
>>>
>>> What I really want is that part of my view hierarchy to be free to use -setFrame:, but other parts use the autolayout constraints normally.
>>
>> Can't you simply set translatesAutoresizingMaskIntoConstraints = NO on the views in question? Then you should be free to manipulate such views' frames at will without interfering in any related constraints.
>
> Not sure if you’ve got this backwards, or are unaware of a certain frameworks bug.
>
> Views whose translatesAutoresizingMaskIntoConstraints property is set to YES can be positioned via -setFrame:. Views whose property is set to NO must be positioned via constraints.
>
> Theoretically, you could still use -setFrame: to position views whose translatesAutoresizingMask property is set to NO (and I believe Apple even said that you could), but it turns out that Auto Layout evaluates *every* view in the window and sets and un constrained variables to zero. That means that if a layout pass happens to occur at any point, your view will effectively disappear as its frame is set to NSZeroRect.
>
> I filed this a long time ago, but I doubt it will ever get fixed. :(
That's not a bug. If you're opting into autolayout by setting translatesAutoresizingMask to NO, your view's "frame" property has no meaning. Autolayout changes your views' frames at will, as it pretty much has to in order to do what it does. If you are using autolayout, you use constraints to position your views programmatically.
Charles
_______________________________________________
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