Re: Quickie about constraints
Re: Quickie about constraints
- Subject: Re: Quickie about constraints
- From: Graham Cox <email@hidden>
- Date: Mon, 18 Aug 2014 09:18:52 +1000
On 16 Aug 2014, at 4:10 pm, Kyle Sluder <email@hidden> wrote:
> 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.
Can you provide some more info on this? It certainly has me confused - the name of that method *appears* to hint that by passing NO you're telling the system you will handle a view's layout, so skip it when evaluating constraints. If that's not what it does, it is very badly named - no doubt it made sense to someone at the time, but when approaching constraints for the first time, it's very misleading.
My assumption about this method is that it permits the translation of masks once, when the view is set up, rather than each time the constraints have to be solved. If it is the latter however, that may be why the sense of its parameter appears to be back to front.
> 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 do seem to have a situation where my view disappears when I try to resize it via -setFrame:, though not when the window is resized. I don't want that to happen, so what do I do to stop the constraints system from even touching it?
I've removed the constraints in IB and am now passing -setTranslatesAutoreszingMaskIntoConstraints:YES as suggested, and my view isn't disappearing any more. -setFrame: also seems to be working, so this might be all I need to do. I'm a bit reluctant to call it solved though, because my understanding of what's going on is no clearer. In fact, the opposite.
--Graham
_______________________________________________
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