UIScrollView和约束 [英] UIScrollView and Constraints
问题描述
故事板:
预览:
检查是否向您的数据视图添加了以下约束:
- 转到故事板 - >选择视图
- 现在在右下角,您可以看到小按钮添加约束。
- 选择固定并标记所有边的所有4个约束
- 将全部4个约束添加到视图中
EDIT
我已按照您的说明创建了一个演示。
ImageConstraint演示
为设置所有约束UIScrollView
和 UIImageView
,并完美地工作。
以下是您的参考图片。
故事板:
$ b b
>
关注以下步骤
步骤1:在故事板中选择 UIView
- >编辑器 - >解决布局问题
p>
步骤-2:重复此操作添加约束
步骤3:选择 UIScrollView
并从右下角添加约束
步骤4:选择 UIImageView
并为其添加约束。
I'm trying to place a UIImageView at the top of a UIScrollView and when I constrain the UIScrollView to the sides of the View Controller and constrain the UIImageView to the top and make the width of the UIImageView equal to the UIScrollView it makes the UIImageView way wider than the UIScrollView, and much taller than expected. Any idea what I'm doing wrong?
Storyboard:
Preview:
Check that following constraints are added to your view:
- Go to Storyboard -> Select your view
- Now at right-bottom corner you can see small buttons to add constraints
- Select "Pin" button
- And mark all 4 constraints for all sides
- Add all 4 constraints to your view
EDIT
I have created one demo as you described.
ImageConstraint Demo
Set all constraints for UIScrollView
and UIImageView
and works perfectly.
Below are reference images for you.
Storyboard:
FOLLOW BELOW STEPS
Step - 1 : In storyboard Select UIView
-> Editor -> Resolve layout issues
Step - 2 : Repeat same to add constraint
Step - 3 : Select UIScrollView
and add constraint from right-bottom corner
Step - 4 : Select UIImageView
and add constraint for it.
这篇关于UIScrollView和约束的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!