简体   繁体   English

具有自动布局的UIView不会增加UIScrollView内的高度

[英]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: 需要删除UIScrollViewcontentView任何高度限制,并添加一个底部限制,如下所示:

在此处输入图片说明

Updated the sample app with this change. 使用此更改更新了示例应用程序。 Now the sample app works as expected. 现在,示例应用程序可以按预期运行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在不使用自动布局的情况下增加UIView的高度 - Increase height of UIView without Auto Layout UIView不在UIScrollView中垂直滚动 - UIView doesn't scroll inside UIScrollView in vertical 在目标c中启用自动布局时如何增加uiview的高度 - How to increase height of uiview when auto layout is enabled in objective c 为什么我的UIScrollView中的UIView不尊重其高度约束? - Why my UIView inside UIScrollView doesn't respect its height contraint? 具有动态高度的容器视图,具有自动布局的UIScrollView - Container view with dynamic height inside UIScrollView with auto layout UIView在UIScrollview中不移动 - UIView doesn't move in UIScrollview 编程自动布局不计算 UIScrollView 的高度 - Programmatic auto-layout not calculating height of UIScrollView UIView内的动态UITextview(又位于UIScrollview内),如果加载了长文本,则启用自动布局的所有视图均会出现故障 - Dynamic UITextview inside a UIView, which inturn is inside a UIScrollview, all views enabled with auto layout malfunctions if long text loaded 具有自动布局的UIView最小和最大高度 - UIView min and max height with Auto Layout UIStoryBoard Auto Layout在UIScrollView内嵌入UIStackView - UIStoryBoard Auto Layout embed UIStackView inside UIScrollView
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM