Constraint Help

I need some help with some constraints (sample project attached)
I am not sure if it is a chicken and egg problem but I have a table and a canvas on a screen.

  • In portrait view I want the canvas full width and the table to stop at the top of the canvas.
  • In Landscape I want the table to be full height and the canvas to go from the last screen edge to the left table edge

https://www.rushsoftware.com.au/Files/Constraint%20Example.xojo_binary_project

If I delete the constraint from auto layout and create it in code it works on opening the app but it doesn’t respond when I rotate it. Is it a priority thing, I’m just not getting it… the logic seems simple??

Still not getting anywhere, Im trying to make a canvas 2/3 of the landscape width but it always goes the full width

Var right As New iOSLayoutConstraint(Canvas1, _
iOSLayoutConstraint.AttributeTypes.Right, _
iOSLayoutConstraint.RelationTypes.Equal, _
self, iOSLayoutConstraint.AttributeTypes.right, _
0.66, 0, 1000)

Try to have at least 2 of them (left and right) equal to the parent items
then add the contraints to the parent (Screen).

Var leftAs New iOSLayoutConstraint(Canvas1, iOSLayoutConstraint.AttributeTypes.Left, _
iOSLayoutConstraint.RelationTypes.Equal, _
self, iOSLayoutConstraint.AttributeTypes.Left, _
1.0, 1.0)
Var right As New iOSLayoutConstraint(Canvas1, iOSLayoutConstraint.AttributeTypes.Right, _
iOSLayoutConstraint.RelationTypes.Equal, _
self, iOSLayoutConstraint.AttributeTypes.right, _
1.0, 1.0)
Self.AddConstraint(left)
Self.AddConstraint(right)

Something like that.

Better sample is here (copy and paste the full url in the browser):
https://documentation.xojo.com/api/ios/ioslayout.htmlConstraint.Constructor(firstItem_As_Object,_firstAttribute_As_AttributeTypes,_relation_As_RelationTypes,_secondItem_As_Object,_secondAttribute_As_AttributeTypes,_multiplier_As_Double,_addend_As_Double,priority_As_Double%3D_1000)

1 Like