gpt4 book ai didi

ios - 使用自动布局约束根据 UITableViewCell 内容高度调整 UIImageView 的大小

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:36:17 25 4
gpt4 key购买 nike

我有一个具有以下 View 的 UITableViewCell xib: enter image description here

如图所示,它具有以下组件:

  1. UILabel - 日期标签
  2. UILabel - 地址标签
  3. UILabel - criteriaLabel
  4. UIImageView - separatorImageView

因为我想根据标签中的内容增加单元格的高度,所以我为每个标签添加了以下约束:

enter image description here

所以 dateLabel 约束是:

enter image description here

addressLabel 约束是:

enter image description here

criteriaLabel 约束是:

enter image description here

不为 separatorImageView 添加约束,单元格显示如下:

enter image description here

即。单元格根据完美的内容调整大小:)

现在的问题是 - 如果我向 separatorImageView 添加以下约束:

enter image description here

细胞开始像这样出现:

enter image description here

请建议我应该向 separatorImageView 添加哪些约束,以便它根据单元格的高度调整大小,而不影响单元格的正确调整大小。

最佳答案

也许这不是最好的答案,但对于特殊情况我会这样做:

  1. 创建一个名为 resizingVIEW 的 UIView,将其固定到 super View (contentView) 的顶部、底部、尾部、前导

  2. 移除separatorImageView 底部空间约束

  3. ctrl+click from separatorImageView to resizingVIEW,选择等高

(注意设置 resizingVIEW 背景颜色以清除颜色/或隐藏它)

关于ios - 使用自动布局约束根据 UITableViewCell 内容高度调整 UIImageView 的大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30371547/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com