简体   繁体   English

iOS在TableView内部的内容视图中存在图像对齐问题

[英]ios having alignment issues of an image in an content view inside a tableview

I have a custom cell inside an UITableView . 我在UITableView有一个自定义单元格。 Within that custom cell I am trying to put an image and to vertically align it horizontally. 在该自定义单元格中,我尝试放置图像并将其水平垂直对齐。 As soon as I do that I get that red line. 一旦我这样做,我就会得到那条红线。
I have clicked the update frames button, there were no pop up of a menu to select any options. 我单击了更新框架按钮,没有弹出菜单来选择任何选项。

Heres an image to get a better understanding. 继承人的形象,以获得更好的理解。
What do I need to do to fix it? 我需要做什么来修复它?

我的自定义单元格的图像

The constraints for your image view are not sufficient for Auto Layout to know where & how big the image view should be: 图像视图的约束不足以使自动版式知道图像视图的位置和大小:
Constraints for views need to specify the position (x, y) plus the size of the view (width, height). 视图约束必须指定位置(x,y)加上视图大小(宽度,高度)。

To fix your issue, add constraints for: 要解决您的问题,请添加以下约束:

  1. leading 领导
  2. trailing, or width 尾随或宽度
  3. top 最佳
  4. bottom, or height 底部或高度

You could also press Add missing constraints in the menu that pops up when you press that |△| 您也可以在按|△|时弹出的菜单中按添加缺失约束 button, but I discourage you from doing so, because then it might add constraints you were not actually looking for. 按钮,但我不鼓励您这样做,因为这样可能会增加您实际上并没有寻找的约束。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM