<legend id='9aJyF'><style id='9aJyF'><dir id='9aJyF'><q id='9aJyF'></q></dir></style></legend>

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

      1. <small id='9aJyF'></small><noframes id='9aJyF'>

      2. <tfoot id='9aJyF'></tfoot>

        如何防止 AutoLayout 重置视图框架?

        时间:2023-09-11
              <tbody id='zxKcf'></tbody>
            <legend id='zxKcf'><style id='zxKcf'><dir id='zxKcf'><q id='zxKcf'></q></dir></style></legend>
          • <small id='zxKcf'></small><noframes id='zxKcf'>

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

                <tfoot id='zxKcf'></tfoot>

                  本文介绍了如何防止 AutoLayout 重置视图框架?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有一个带有 AutoLayout 的视图,它适用于不同的屏幕尺寸.屏幕上有一个元素,但它会根据用户操作四处移动.每当我向下导航到另一个屏幕然后返回此视图时,此元素都会重置为其原始位置.

                  I have a view with AutoLayout and it works nicely with different screen sizes. There's one element on the screen though that moves around depending on user actions. Whenever I navigate down to a different screen then back to this view, this element gets reset to its original position.

                  我明白为什么会发生这种情况,但我该如何预防呢?我确实希望它最初设置正确,但不是在第一次之后.

                  I understand why this happens but how can I prevent it? I do want it to be setup correctly initially but not after the first time.

                  推荐答案

                  如果你使用 Autolayout,你永远不应该使用 setFrame/setBounds,因为你已经看到 Autolayout 会忽略它们并在更新时重写它们.

                  If you're using Autolayout you should never use setFrame/setBounds because as you've seen Autolayout ignores them and rewrites them when it updates.

                  解决办法是改变约束.约束有一个名为 constant 的参数,这是创建约束后唯一可以更改的参数.当您需要移动 NSViews 时,您还可以添加/删除额外的约束.

                  The solution is to change the constraints. A constraint has a parameter called constant which is the only thing you can change on a constraint after it has been created. You can also add/remove extra constraints when you need to move NSViews around.

                  WWDC 2012 上有一个视频,其中有一个非常好的示例,说明如何使用 AutoLayout 移动视图.

                  There is a video from WWDC 2012 that had a very good example of how to move views with AutoLayout.

                  这篇关于如何防止 AutoLayout 重置视图框架?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:我想将表格视图精确放置到导航栏 下一篇:出现键盘时移动具有自动布局约束的文本字段

                  相关文章

                  • <bdo id='mGcLW'></bdo><ul id='mGcLW'></ul>
                  <tfoot id='mGcLW'></tfoot>

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

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