Designing custom views with Xcode 11.2 (11B52) or 11.2.1 (11B500), I met some situations where I cannot create constraints onto the view and its subviews.
It may be hard to reproduce since it is embedded in an existing project, but in this particular, just creating an empty view via :
File → New → File... → User Interfaces → View
If I add some components from the object library, then I cannot add constraints via Ctrl-click or the bottom right icon
In my previous attempt, I correctly bound it to my swift class, even if there was no controller yet.
I suspect I wrongly configured something related the "Auto Layout" feature, but have no clue where it is now. If I copy/paste a tree view from a existing storyboard where the constraints are properly editable, then it is possible to add constraints without issue.
The side-by-side comparison does not show any obvious difference in the various inspectors.
What is the right approach to avoid these constraint locking issues ?
There is probably a configuration issue somewhere in this existing project,
But in the meantime, to anyone falling in this use case, a possible workaround is to set Automatic
in the Layout
section of the Size inspector. By default, in my existing project, it is set to Translates Mask Into Constraints
each time I create a new view and add object via the Object Library.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With