UIScrollView 的AutoLayout
来源:互联网 发布:贾森威廉姆斯生涯数据 编辑:程序博客网 时间:2024/05/21 15:46
UIScrollView 和 AutoLayout 使用时经常会出现模糊约束的问题。这是因为scollview 滑动的范围是由contentSize决定的,而这个contentSize 又具体来说是由它view 填充的内容决定的。下面说一下UIScrollview 在AutoLayout 上的使用。
1、将UIScrollView添加到UIView控件中,并设置UIScrollView针对父视图UIView的constraints(Leading/trailling/top/bottom = 0) Tips:如果已经布局了一些控件了,想要内嵌到一个scrollView 或者View 中可以先选中这几个控件,然后点击Xcode 最上面的Editor 工具,选择Embed in ,再选择view 或者scrollView 即可。
2、添加UIView控件到UIScrollView中。
(1)并改名为contentView.(用来包含那些真正要布局的控件)
(2)然后设置contentView的针对父视图UIScrollView的 constraints
1、Leading/trailling/top/bottom= 0
2、 equal width (contentView的宽度 与 UIScrollView相等)
(3)将要添加的那个控件添加到contentView 下作为子 view,关键的是要将里面的subView的控件大小定好,然后subView 之间的距离定好,相对于contentView 的距离也定好,最后就会决定了contentView 的高度,然后就可以确定scrollView的contentSize 了。
示例代码Demo下载:
这里写链接内容
- autolayout下的uiscrollview
- UIScrollView 的AutoLayout
- Autolayout---UIScrollView的一些问题
- AutoLayout UIScrollView
- UIScrollview AutoLayout
- Autolayout下的UIScrollView的适配
- UIScrollview与Autolayout的那点事
- UIScrollView 使用AutoLayout布局遇到的问题
- UIScrollView添加AutoLayout约束的坑
- UIScrollView添加AutoLayout约束的坑
- UIScrollView添加AutoLayout约束的坑
- UIScrollview与Autolayout的那点事
- iOS UIScrollView AutoLayout
- UIScrollView and Autolayout
- UIScrollView + AutoLayout结合使用
- UIScrollView遇上AutoLayout
- 当UIScrollView 遇到 autolayout
- UIScrollView和AutoLayout
- linux指令学习之内存
- android ProgressBar属性
- Android6.0权限
- MathJax 规则
- 通道——制作光影效果——猫の物語
- UIScrollView 的AutoLayout
- 获取当前设备的UUID和经纬度
- ImportError: libclntsh.so.11.1: cannot open shared object file: No such file or directory解决方案
- 一个printf引发的问题
- 机器学习中的算法(1)-决策树模型组合之随机森林与GBDT
- 用 Eclipse 插件提高JAVA 代码质量
- iOS -- textfield输入时键盘升起,改变view高度
- 常用类-NSMutableDictionary
- 数据结构3_160805无头单向不循环