且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

UIScrollView 和约束

更新时间:2023-02-04 10:53:10

检查以下约束是否添加到您的视图中:

  1. 转到故事板 -> 选择您的视图
  2. 现在在右下角,您可以看到用于添加约束的小按钮
  3. 选择固定"按钮
  4. 并标记所有边的所有 4 个约束
  5. 将所有 4 个约束添加到您的视图中

编辑

我已经按照您的描述创建了一个演示.

EDIT

I have created one demo as you described.

UIScrollViewUIImageView 设置所有约束并完美运行.

Set all constraints for UIScrollView and UIImageView and works perfectly.

以下是供您参考的图片.

Below are reference images for you.

Step - 1 : 在 storyboard 中选择 UIView -> Editor -> Resolve layout issues

Step - 1 : In storyboard Select UIView -> Editor -> Resolve layout issues

Step - 2 : 重复同样的操作来添加约束

Step - 3 : 选择 UIScrollView 并从右下角添加约束

Step - 3 : Select UIScrollView and add constraint from right-bottom corner

Step - 4 : 选择 UIImageView 并为其添加约束.

Step - 4 : Select UIImageView and add constraint for it.