<legend id='4nqkp'><style id='4nqkp'><dir id='4nqkp'><q id='4nqkp'></q></dir></style></legend>
<tfoot id='4nqkp'></tfoot>
    • <bdo id='4nqkp'></bdo><ul id='4nqkp'></ul>

    <small id='4nqkp'></small><noframes id='4nqkp'>

    1. <i id='4nqkp'><tr id='4nqkp'><dt id='4nqkp'><q id='4nqkp'><span id='4nqkp'><b id='4nqkp'><form id='4nqkp'><ins id='4nqkp'></ins><ul id='4nqkp'></ul><sub id='4nqkp'></sub></form><legend id='4nqkp'></legend><bdo id='4nqkp'><pre id='4nqkp'><center id='4nqkp'></center></pre></bdo></b><th id='4nqkp'></th></span></q></dt></tr></i><div id='4nqkp'><tfoot id='4nqkp'></tfoot><dl id='4nqkp'><fieldset id='4nqkp'></fieldset></dl></div>

        如何根据使用 Autolayout 布局的子视图的大小调整父视图的大小

        How to resize a parent view based on the size of subviews layouted with Autolayout(如何根据使用 Autolayout 布局的子视图的大小调整父视图的大小)
            <tbody id='P2P6r'></tbody>

            <i id='P2P6r'><tr id='P2P6r'><dt id='P2P6r'><q id='P2P6r'><span id='P2P6r'><b id='P2P6r'><form id='P2P6r'><ins id='P2P6r'></ins><ul id='P2P6r'></ul><sub id='P2P6r'></sub></form><legend id='P2P6r'></legend><bdo id='P2P6r'><pre id='P2P6r'><center id='P2P6r'></center></pre></bdo></b><th id='P2P6r'></th></span></q></dt></tr></i><div id='P2P6r'><tfoot id='P2P6r'></tfoot><dl id='P2P6r'><fieldset id='P2P6r'></fieldset></dl></div>

              <small id='P2P6r'></small><noframes id='P2P6r'>

            • <legend id='P2P6r'><style id='P2P6r'><dir id='P2P6r'><q id='P2P6r'></q></dir></style></legend>

                <bdo id='P2P6r'></bdo><ul id='P2P6r'></ul>
                <tfoot id='P2P6r'></tfoot>
                1. 本文介绍了如何根据使用 Autolayout 布局的子视图的大小调整父视图的大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在准备一个与屏幕截图中显示的示例类似的自定义视图.我在运行时添加所有用户界面组件(标签、文本字段、单选按钮……).要定位我使用的元素 自动布局 约束.到目前为止,这部分工作正常.

                  I am preparing a custom view which looks similar to the example shown in the screenshot. I add all user interface components (labels, text fields, radio buttons, ..) at runtime. To position the elements I use Autolayout constraints. This part works fine so far.

                  元素的数量因上下文而异.我想知道如何使用 Autolayout 约束来动态调整父视图的大小(很可能是视图的高度).因此,视图约束应考虑为当前附加的子视图定义的高度和边距.

                  The number of elements varies from context to context. I wonder how I could use Autolayout constraints to dynamically resize the parent view (most likely the height of the view). The view constraints therefore should consider the height and margins defined for the currently attached subviews.

                  推荐答案

                  我已经通过以下设置完成了这个:

                  I've done this with the following setup:

                  • 容器视图没有高度限制
                  • 顶部子视图与容器视图顶部有间距约束
                  • 包含的视图之间都有间距限制
                  • 底部视图对容器视图底部有间距限制

                  自动布局系统通过调整容器大小以适应其内容来满足这些约束.

                  The auto layout system satisfies these constraints by resizing the container to fit its contents.

                  当然,您需要在更改内容时动态设置约束.

                  Of course, you need to dynamically set the constraints as you alter the contents.

                  这篇关于如何根据使用 Autolayout 布局的子视图的大小调整父视图的大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Hardware Volume buttons change in app volume(硬件音量按钮更改应用程序音量)
                  Cocos2d - How to check for Intersection between objects in different layers(Cocos2d - 如何检查不同层中对象之间的交集)
                  How to convert 32 bit PNG to RGB565?(如何将 32 位 PNG 转换为 RGB565?)
                  Proper cocos2d scene restart?(正确的 cocos2d 场景重启?)
                  Game center facebook like(游戏中心 facebook 喜欢)
                  Objective-C++ importing C++ class fails, cassert not found(Objective-C++ 导入 C++ 类失败,未找到 cassert)
                      <tfoot id='hxeyc'></tfoot>

                      1. <legend id='hxeyc'><style id='hxeyc'><dir id='hxeyc'><q id='hxeyc'></q></dir></style></legend>

                            <tbody id='hxeyc'></tbody>
                          <i id='hxeyc'><tr id='hxeyc'><dt id='hxeyc'><q id='hxeyc'><span id='hxeyc'><b id='hxeyc'><form id='hxeyc'><ins id='hxeyc'></ins><ul id='hxeyc'></ul><sub id='hxeyc'></sub></form><legend id='hxeyc'></legend><bdo id='hxeyc'><pre id='hxeyc'><center id='hxeyc'></center></pre></bdo></b><th id='hxeyc'></th></span></q></dt></tr></i><div id='hxeyc'><tfoot id='hxeyc'></tfoot><dl id='hxeyc'><fieldset id='hxeyc'></fieldset></dl></div>

                            <bdo id='hxeyc'></bdo><ul id='hxeyc'></ul>

                            <small id='hxeyc'></small><noframes id='hxeyc'>