Constraints in stack view causing weird issue

205 views Asked by At

I am using Xcode 9 Beta 6, and following a Devslopes tutorial. In the tutorial we are putting two images in a horizontal stack view, and setting it to Fill Equally. Also on one of the images we are putting two constraints, Width <= 140 and aspect-ratio 1:1. When I go to add new constraints and pin the stack view 8 to the left and right, and 24 to the top the view gets extremely large and goes off of the phone and pushes other items with it. I'm not sure why this is happening.

enter image description here

Finished Version I am going for: enter image description here

1

There are 1 answers

0
Martin Muldoon On

I've duplicated your issue, and what I have found is that your constraint where you are setting width on your Data Image <= 140 seems to be the issue. You are setting your stack view to fill equally. This is a conflict. How can one image be <= 140, while you are filling equally? I'm fairly certain this is the cause of your problem.

In the image below, I've set my Stack View to fill, pinned it left and right at 8 and set the image on the left to 140 and it works fine. In Attributes Inspector, set the Spacing Attribute on the Stack View to get the space between images as you desire.

enter image description here