滚动视图不垂直滚动 [英] scroll view not scrolling vertically

查看:76
本文介绍了滚动视图不垂直滚动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个滚动视图,它根本没有滚动:

I have a scroll view that it not scrolling at all:

    scroll_view_content_a_job.contentSize.height = 1800
    scroll_view_content_a_job.isScrollEnabled = true

推荐答案

您在滚动视图中使用约束,因此内容大小由约束而不是通过在代码中设置contentSize来确定.您需要修复约束,以便它们从滚动视图的内到外调整内容的大小.滚动视图的顶部子视图需要固定到滚动视图的顶部,而底部子视图则需要固定到滚动视图的底部,并且两者之间的所有视图都必须彼此固定,以指示所需内容的大小高度.但是需要将滚动视图本身固定到其超级视图,以使其不比屏幕高.换句话说,当滚动视图的约束高度 的总和大于滚动视图的约束高度 时,这将起作用.

You're using constraints in your scroll view, so the content size is determined by the constraints, not by setting the contentSize in code. You need to fix your constraints so that they size the content from the inside out of the scroll view. The top subview of the scrollview needs to be pinned to the scrollview's top, and the bottom subview needs to be pinned to the scrollview's bottom, and all the views in between need to be pinned to one another, in such a way as to dictate the desired content size height. But the scroll view itself needs to be pinned to its superview, so that it is not taller than the screen. In other words, this will work when the sum of the constrained heights inside the scroll view is greater than the constrained height of the scroll view.

这篇关于滚动视图不垂直滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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