Andy
Andy

Reputation: 479

Auto layout issue with a row of image views

This is driving me nuts!

I am trying to show a row of images of followers to a profile in my app. The idea is for it to be 5 images where you could theoretically click on them and move to their profile.

Here is what I am having troubles with now :

Autolayout hell

I've never had to ask about auto layout before so I don't know what to show you all for your help. Is feel like this is a silly problem...

Here is the setup:

Any help would be appreciated.

EDIT: So as per Michal I tried a stack view and although it seemed like the right thing to do it honestly gave me the same results, so I am sure I am doing this wrong. Please see images below

enter image description here enter image description here

Upvotes: 0

Views: 317

Answers (1)

MSU_Bulldog
MSU_Bulldog

Reputation: 3519

I figured I would make this an answer so that the comments don't get too long. So, with everything these are the constraints you should have added:

1) Set all UIImageView's to have equal widths

2) Set all UIImageView's aspect ratio constraint

3) Add a height constraint to each UIImageView

4) Set all UIImageView's to have equal heights, just like with width in step 1

5) Set leading and trailing space constraints for each UIImageView. This one is a little tricky. The first UIImageView should have a leading constraint = x. The last UIImageView should have a trailing constraint = x. The constraints between each UIImageView should be >= x.

This is the icon for selecting constraints:

enter image description here

Upvotes: 1

Related Questions