所以我在最新 Xcode 的视图控制器中使用了 UIScrollView
.我在滚动视图中有按钮.当我运行应用程序时,滚动视图消失了.谁能告诉我是什么原因造成的以及自动布局工具是如何工作的?
So I'm using a UIScrollView
in a view controller in the latest Xcode. I have buttons inside the scroll view. When I run the application, the scroll view disappears. Can anyone tell me what is causing this and how the auto layout tools work?
按照这些步骤,
获取滚动视图并相对于父视图设置约束(前导、尾随、顶部、底部).并为其设置一些背景颜色,使其在运行时可见.
Take scroll view and set constraints (leading, trailing, top, bottom) with respect to the parent view. And set some background color to it so that it will visible at run time.
将 UIButton 放在滚动视图上,然后设置按钮(前导、尾随、顶部)相对于滚动视图的约束,并设置按钮的宽度和高度约束,以及一些背景按钮的颜色,以便在运行时可见.
Take UIButton and place it over scrollview, and then set constraints for your button (leading, trailing, top) with respect to the scroll view, and also set the width and height constraints for button ,and also some background color to button so that it will visible at runtime.
注意:你的内容的层次应该是这样的——-父视图-滚动视图-按钮
Note: The hirearchy of your contents should be like this- -parentView -ScrollView -button
如果有什么不清楚的地方请告诉我.
please let me know if anything is not clear.
谢谢.
这篇关于如何在滚动视图中使用自动布局?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!