[英]Scroll view and Stack view
I've read everything I could find about stacks with scroll views but nothing helps me.我已经阅读了我能找到的关于带有滚动视图的堆栈的所有内容,但没有任何帮助。
I want to have vertical scroll because I have some labels in stack view and sometimes there are all labels sometimes there are not.我想要垂直滚动,因为我在堆栈视图中有一些标签,有时有所有标签,有时没有。 According to this, I want to make scroll when needed.
据此,我想在需要时进行滚动。 Here is a visual representation of my problem.
这是我的问题的直观表示。
How could I achieve this?我怎么能做到这一点? Do I have to code something or do some adjustments on storyboard?
我是否必须编写代码或对故事板进行一些调整?
You can use contentSize
property of UIScrollView
for this purpose.为此,您可以使用
UIScrollView
contentSize
属性。
scrollview.contentSize = CGSizeMake(contentWidth, contentHeight)
This property sets content size of the scrollview.此属性设置滚动视图的内容大小。
Lets take example, consider you have scrollview whose height is 480 and width is 320让我们举个例子,假设你有一个高度为480 ,宽度为320 的滚动视图
If you want horizontal scrolling then set contentWidth
greater then 320 and if you want vertical scrolling set contentHeight
greater then 480如果你想要水平滚动然后设置
contentWidth
大于 320,如果你想要垂直滚动设置contentHeight
大于 480
For your problem it should be like this对于你的问题,它应该是这样的
yourscrollview.contentSize = CGSizeMake(your scrollview Width, Y of Last label + height of Last Label)
And don't forget to set并且不要忘记设置
scrBudgetList.scrollEnabled = true;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.