• <bdo id='kMb6n'></bdo><ul id='kMb6n'></ul>

      <legend id='kMb6n'><style id='kMb6n'><dir id='kMb6n'><q id='kMb6n'></q></dir></style></legend>

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

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

      删除视图时约束会发生什么

      时间:2023-09-11

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

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

              <tfoot id='GN0nT'></tfoot>
              <legend id='GN0nT'><style id='GN0nT'><dir id='GN0nT'><q id='GN0nT'></q></dir></style></legend>
                <tbody id='GN0nT'></tbody>
              • 本文介绍了删除视图时约束会发生什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我的问题很简单,但我在文档中找不到任何信息.

                The question I have is simple but I couldn't find any information in the documentation.

                当视图从视图层次结构中移除(或移动到另一个视图)时,布局约束会发生什么情况?

                What happens with layout constraints when a view is removed from the view hierarchy (or moved to another view)?

                例如,让我们有容器 C 与子视图 AB.容器 C 包含一些约束.然后我们调用 [A removeFromSuperview].A 的约束会发生什么?

                For example, let's have container C with subviews A and B. Container C holds some constraints. Then we call [A removeFromSuperview]. What happens with the constraints for A?

                如果我们再次将 A 添加到 C 会发生什么?

                What then happens if we add A to C again?

                推荐答案

                约束被移除.如果再次添加 A,则必须为其创建新的约束,或者如果在删除 A 之前保存约束,则可以重新添加它们.当我做这样的事情时,我会为一个名为 view1 的视图保存这样的约束:

                The constraints are removed. If you add A again, you will have to make new constraints for it, or if you save the constraints before you remove A, you can add them back. When I do something like this, I save the constraints like this for a view called view1:

                self.portraitConstraints = [NSMutableArray new];
                for (NSLayoutConstraint *con in self.view.constraints) {
                    if (con.firstItem == self.view1 || con.secondItem == self.view1) {
                       [self.portraitConstraints addObject:con];
                    }
                }
                

                这篇关于删除视图时约束会发生什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:创建具有自动布局约束的 3x3 网格 下一篇:即使有足够的空间可用于单词,UILabel 自动换行功能也会留下空间

                相关文章

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

                1. <tfoot id='6SbOY'></tfoot>
                    <bdo id='6SbOY'></bdo><ul id='6SbOY'></ul>

                    <small id='6SbOY'></small><noframes id='6SbOY'>

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