具有自动布局的UIView不会增加UIScrollView内的高度 [英] UIView with Auto Layout doesn't increase height inside UIScrollView

查看:82
本文介绍了具有自动布局的UIView不会增加UIScrollView内的高度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想做的是有一个类似于以下线框的页面,所有UILabel的高度都应根据文本动态变化:

What I'm trying to do is have a page similar to following wireframe that all UILabels height should dynamically change based on the text:

我目前在UIScrollView中有一个UIView.问题是我无法根据其内容正确调整UIView的大小,例如,当描述很长时.可以从此处

I currently have a UIView inside a UIScrollView. The issue is I can't get the UIView resize properly based on the its content, for example when description is long. The sample code can be downloaded from here

如果不喜欢编写代码,请遵循以下约束及其设置方式:

If not into the mood for code, here's the constraints and how it's setup:

我尝试使用这篇文章

推荐答案

最终,找到了解决方案.需要删除UIScrollViewcontentView的任何高度限制,并添加一个底部限制,如下所示:

FINALLY, found the solution to it. Needed to remove any height constraint for UIScrollView and contentView and add a bottom constraint as shown below:

使用此更改更新了示例应用程序.现在,示例应用程序可以按预期运行.

Updated the sample app with this change. Now the sample app works as expected.

这篇关于具有自动布局的UIView不会增加UIScrollView内的高度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆