【问题标题】:Table View Custom Cell... Giving the constrains but it is not working表视图自定义单元格...给出约束但它不起作用
【发布时间】:2018-03-23 00:29:15
【问题描述】:

我创建了一个带有表格视图单元格的表格视图控制器以及 XIB 文件...实际表格应该如下所示 (image of Table view to be created)。我在 XIB 文件中给出了所有约束(附有屏幕截图)(screenshot of XIB look),但是当我运行模拟器时,创建的表非常混乱,并且没有满足我的任何约束(screenshot of table created)。我错过了什么?我应该更改任何表格视图/单元格设置吗?

我的限制包括: 对于投射图像: 监督空间:8 监督的底部空间:5 可查看的顶部空间:5 将图像比例宽度投射到超级视图:0.3

所有四个标签都放置在堆栈视图中,并限制顶部空间、前导空间和尾随空间集

logo图片的底部空间和尾部空间设置为superview,宽度设置为50,高度设置为50

提前致谢

【问题讨论】:

  • 说真的……那些截图。
  • 细胞的高度如何? - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath;
  • 是的,我也在 tableview 控制器文件中设置了它。它不仅与高度有关,而且与标签有关,图像一切都搞砸了

标签: uitableview custom-cell


【解决方案1】:

我只能写下应该如何设置。

个人资料图片:

Set top bottom leading to super view, 8 offset on all.
Set width to superview with a multiplier of 0.3
Set contentType to scaleAspectFit
Set height to maybe 144?

堆栈视图:

leading to profile image, maybe 8 offset here as well?
top to profile image top
trailing to superview
bottom to logo image

标志图片:

bottom and trailing to super view offset 8
height and width to 50

【讨论】:

  • 我设置了与我在问题中提到的相同的约束,但它没有帮助
  • 你有适合的 contentType scaleAspect 吗?并且您还需要图像高度,(更新答案)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-11-26
  • 2016-10-17
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多