的UIScrollView和约束 [英] UIScrollView and Constraints

查看:126
本文介绍了的UIScrollView和约束的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图把一个UIImageView在一个UIScrollView的顶部,当我约束的UIScrollView到视图控制器的两侧和约束的UIImageView顶端,使的UIImageView的等于UIScrollView的宽度它使在这样的UIImageView比的UIScrollView宽,高得多超过预期。任何想法,我做错了什么?

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?

情节提要:

preVIEW:

推荐答案

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


  1. 转至故事板 - >选择您的视图

  2. 现在,在右下角你可以看到小按钮来添加约束

  3. 选择按钮

  4. 并标出全部4约束各方

  5. 所有4个约束添加到您的视图

我已创建了一个演示。

将所有约束的UIScrollView 的UIImageView 和完美的作品。

Set all constraints for UIScrollView and UIImageView and works perfectly.

下面是你参考的图片。

第一步 - 1:在故事板选择的UIView - >编辑 - >解决布局问题

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

步骤 - 2:重复相同的添加约束

步骤 - 3:选择的UIScrollView 和右下角添加约束

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

步骤 - 4:选择的UIImageView 并为它添加约束

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

这篇关于的UIScrollView和约束的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆