New Constraints :/

I am trying to understand this new constraint thingy.

Taken from the LR, I placed this in a button :

Dim LeLeft As New iOSLayoutConstraint(TextField1, _ iOSLayoutConstraint.AttributeTypes.Left, _ iOSLayoutConstraint.RelationTypes.Equal, _ self, iOSLayoutConstraint.AttributeTypes.Left, _ 1.0, 50)

I was expecting Left to become 50. Nothing happens. What am I missing ?

Did you already assign constraints to your layout in the IDE? If so, you could end up with conflicting ones.

No, I did not add any named constraints to the control in the IDE. I am precisely trying this new method for me, because all I used one year and a half ago was named constraints.

OK. More. On the same view, I have an instance of ContainerControl, a TextField and a table. Only the ContainerControl moves.

The only difference is that the ContainerControl did not have a Left constraint, only horizontalCenter.

So it seems one can add a constraint, but not modify those that are already set in the IDE.

Yes, I miss a constraints() property where you can see all constraints – not only retrieve ones you know the names of – too.
But I am sorry, I missed the bug above: After defining a constraint, you must add it to the iOSView using addConstraint. Works for me with your code slightly modified.

Michel, this should work:

Dim LeLeft As New iOSLayoutConstraint(TextField1, _ iOSLayoutConstraint.AttributeTypes.Left, _ iOSLayoutConstraint.RelationTypes.Equal, _ self, iOSLayoutConstraint.AttributeTypes.Left, _ 1.0, 50) LeLeft.Active = True self.AddConstraint(LeLeft)

[quote=288589:@Ulrich Bogun]Yes, I miss a constraints() property where you can see all constraints – not only retrieve ones you know the names of – too.
But I am sorry, I missed the bug above: After defining a constraint, you must add it to the iOSView using addConstraint. Works for me with your code slightly modified.[/quote]
For what it’s worth, there’s an app called Reveal which lets you see all of the layers and constraints. We use this for debugging layout issues in the XDC iOS app.

Interesting, thanks, Greg!
And, FWIW, iOSLib in AppleLib does have a constraints() property. I started experimenting with the new layoutAnchors in it but I usually end up resizing exactly the wrong view :smiley: