How do you use auto layout in a scroll view?(如何在滚动视图中使用自动布局?)
问题描述
所以我在最新 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.
谢谢.
这篇关于如何在滚动视图中使用自动布局?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何在滚动视图中使用自动布局?
基础教程推荐
- iOS4 创建后台定时器 2022-01-01
- Android:getLastKnownLocation(LocationManager.NETWORK_PROVIDER 2022-01-01
- NSString intValue 不能用于检索电话号码 2022-01-01
- iPhone - 获取给定地点/时区的当前日期和时间并将其与同一地点的另一个日期/时间进行比较的正确方法 2022-01-01
- navigator.geolocation.getCurrentPosition 在 Android 浏览器上 2022-01-01
- 通过重定向链接在 Google Play 中打开应用 2022-01-01
- 如何从 logcat 中删除旧数据? 2022-01-01
- Cocos2d iPhone 非矩形精灵触摸检测 2022-01-01
- AdMob 广告未在模拟器中显示 2022-01-01
- libGDX 从精灵或纹理中获取像素颜色 2022-01-01
