[英]UIView with Auto Layout doesn't increase height inside UIScrollView
What I'm trying to do is have a page similar to following wireframe that all UILabel
s height should dynamically change based on the text: 我想要做的是有一个类似于以下线框的页面,所有UILabel
的高度都应根据文本动态变化:
I currently have a UIView
inside a UIScrollView
. 我目前在UIScrollView
有一个UIView
。 The issue is I can't get the UIView
resize properly based on the its content, for example when description is long. 问题是我无法根据其内容正确调整UIView
大小,例如,当描述很长时。 The sample code can be downloaded from here 可以从此处下载示例代码
If not into the mood for code, here's the constraints and how it's setup: 如果不喜欢编写代码,则这里是约束及其设置方法:
I tried to use the approach mentioned in this post 我试图用中提到的方法这个帖子
FINALLY, found the solution to it. 最终,找到了解决方案。 Needed to remove any height constraint for UIScrollView
and contentView
and add a bottom constraint as shown below: 需要删除UIScrollView
和contentView
任何高度限制,并添加一个底部限制,如下所示:
Updated the sample app with this change. 使用此更改更新了示例应用程序。 Now the sample app works as expected. 现在,示例应用程序可以按预期运行。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.