如何在滚动视图使用自动布局? [英] How do you use auto layout in a scroll view?

查看:118
本文介绍了如何在滚动视图使用自动布局?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我在最新版的X code视图控制器使用的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?

推荐答案

请按照下列步骤操作,

Follow these steps,


  1. 以滚动查看和设置约束(前置,顶部,底部)相对于父视图。并设置一些背景颜色给它,这样它会在运行时可见。

  1. 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.

请注意:你的内容的hirearchy应该像这个 -
    -parentView
      -ScrollView
        -button

Note: The hirearchy of your contents should be like this- -parentView -ScrollView -button

请让我知道,如果有什么不明确。

please let me know if anything is not clear.

感谢。

这篇关于如何在滚动视图使用自动布局?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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