ios - 将 UITableViewCell 的垂直压缩阻力优先级设置为 749

标签 ios swift uitableview autolayout constraints

enter image description here我正在制作一个具有以下约束关系的 TableView 单元格。

    -----------------
    |                |
    |  ____________  |
    |  |          |  |
    |  |__________|  |
    |                |
    |  ____________  |
    |  |label.    |  |
    |  |__________|  |
    |                |
    |  ____________  |
    |  |          |  |
    |  |__________|  |
    |                |
    |  ____________  |
    |  |label.    |  |
    |  |__________|  |
    |________________|

subview 如下:(view, label, view, label)。我希望单元格随两个标签动态调整大小,例如,如果第一个标签变高,则单元格应相应变高。如果两个标签都变得更高或更短,则单元格应相应地调整大小。这两个 View 应该具有恒定的宽度和高度。

如果我从一个标签开始我很好,一个标签和一个 View 我很好,一个标签和一个标签,我很好,但如果我有 2 个标签和一个 View ,只要我把最终标签的最后一个约束,自动布局会在 Storyboard中抛出错误(运行应用程序时我没有看到明显的问题)。

问题是我不想更改抗压性,因为我不想让任何一个标签皱缩,而且我不明白为什么它们会给出提供的约束。

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

最佳答案

将最后一个标签的底部约束修改为具有“大于或等于”关系的常量

你的代码应该是这样的

enter image description here enter image description here

希望这能行得通

关于ios - 将 UITableViewCell 的垂直压缩阻力优先级设置为 749,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54919329/

相关文章:

ios - 如何将图像 UIButton 缩放到插图?

ios - 在 CI 上的 UI 测试不稳定

ios - 从后台返回应用程序时未调用自定义委托(delegate)方法

ios - 我可以对现有的 sqlite 数据库使用 dbaccess 吗?

ios - ScrollsToTop 功能在 iOS9 中无法正常工作

ios - swift 强制将 objective-c int 分配为 Int32 然后崩溃

ios - 如何从自定义 uitableviewcell 推送到新的 View Controller

ios - 如何在 TableView 自定义期间调用方法 "willDisplayFooterView"?

ios - 在 UITableView 中滚动后 UIButton 颜色发生变化

swift - NSLocalizedString( key : value: comment: ) with variable is not working in swift