带有自动布局的 UIScrollview [英] UIScrollview with Auto-Layout

查看:30
本文介绍了带有自动布局的 UIScrollview的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 UIScrollView 上挣扎了一段时间.

I'm struggling with UIScrollView for a while now.

"descriptionLabel" 和 "genresLabel" 将在运行时增加高度,并且与演员的差距将增加.所以我需要这里的滚动功能来查看演员标签.

"descriptionLabel" and "genresLabel" will increase height during runtime and the gap to actors will increase. So i need the scrolling functionality here to see the actors label.

我将 contentView 的高度设置为等于 View 的高度约束,优先级为 250,希望高度会在需要时自动增加.

I set the height of the contentView as a height-constraint equal to View with priority 250 and hoped that the height will increase automatically if needed.

实际上什么也没有发生,也无法滚动.

In fact nothing happens and no scrolling is possible.

如何在自动布局上下文中自动增加 contentView 高度?

How can i automatically increase the contentView height in the auto-layout context?

推荐答案

您必须使 ContentView 的高度灵活,以便它应该增加并且滚动视图的内容大小将相应增加.查看附加的屏幕截图.增加底部标签顶部约束(495)值,滚动视图的内容大小将自动增加.

You have to make ContentView's height flexible so it should get increased and the scrollview's content size will increase accordingly. Have a look into attached screenshots. Increase the bottom label top constraint (which is 495) value the scrollview's content size will get increased automatically.

这是示例源代码

这篇关于带有自动布局的 UIScrollview的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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