带有一行图像视图的自动布局问题 [英] Auto layout issue with a row of image views

查看:246
本文介绍了带有一行图像视图的自动布局问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是让我吃惊!



我想在我的应用程式中显示一排关注者的个人资料图片。



这是我现在遇到的麻烦:





我从来没有问过自动布局不知道什么给你所有的帮助。感觉这是一个愚蠢的问题...



这是设置:




  • 在单独的XIB中设计

  • 所有元素封装在UITableViewCell中



帮助将不胜感激。



编辑:所以根据Michal我试过一个堆栈视图,虽然它似乎是正确的做法,诚实地给了我结果,所以我相信我做错了。请参阅下面的图片





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 :

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:

  • Designed in a separate XIB
  • All elements are encapsulated in a UITableViewCell

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

解决方案

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:

这篇关于带有一行图像视图的自动布局问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆