首页 > 解决方案 > 缺少将 view.top 与动态高度 uilabel 底部连接的约束

问题描述

我正在尝试安排 3 个视图 - 1. 具有固定高度和宽度的图像视图 2. 具有固定宽度但动态高度的 Textview 和 3. 具有固定宽度和高度的 Tableview 根据 textview 之后的可用空间进行调整。

具有突出显示视图的情节提要

我在这里缺少什么限制。为什么我需要给 Textview 或 Tableviews Y pos 或高度约束。这不是让他们的身高固定吗?

错误

标签: iosautolayoutstoryboard

解决方案


You have to put a height constant to your textview. Because autolayout can't figure out how many pixels to give to your both view. If you want to adapt your height depending on the text, you can use :

TextViewHeightConstraint.constant = [TextView intrinsicContentSize].height

into your code after your link your constraint via iboutlet.


推荐阅读