简体   繁体   English

如何强制scrollview在Xcode中只垂直滚动

[英]How to force scrollview to only scroll vertically in Xcode

I want my ScrollView to only scroll vertically but it also scrolls horizontally.我希望我的 ScrollView 只能垂直滚动,但它也可以水平滚动。 I have the leading and trailing constraints set to 0 but somehow it is still adding space to allow it to scroll.我将前导和尾随约束设置为 0,但不知何故它仍在添加空间以允许它滚动。

When I click on the embedded view or scroll view, I see the red lines to the left and right but not sure how to prevent them from being added.当我点击嵌入式视图或滚动视图时,我看到左右两边的红线,但不确定如何防止它们被添加。

在此处输入图像描述

在此处输入图像描述

You must set scrollview's contentView width is equal to superView(device Width).您必须设置 scrollview 的contentView宽度等于 superView(device Width)。 Than after your scrollView stop scrolling horizontal.比在你的 scrollView 停止水平滚动之后。

Thanks.谢谢。

Follow the routine of creating a vertical scroll view.按照创建垂直滚动视图的例程进行操作。

  • First, You need to change Simulated Size to FreeForm.首先,您需要将 Simulated Size 更改为 FreeForm。

  • Second, Put in a ScrollView, set up Constrains.其次,放入一个ScrollView,设置Constrains。

  • Third, Put a View on top of it, set up Constrains.第三,在上面放一个View,设置Constrains。

  • Fourth, set the layout for SuperView.四、设置SuperView的布局。

  • Fifth, change Priority and Mutipier五、改变Priority和Mutipier

And now we can work up here !现在我们可以在这里工作了!

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM