<tfoot id='zDYZy'></tfoot>
  • <small id='zDYZy'></small><noframes id='zDYZy'>

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

        <i id='zDYZy'><tr id='zDYZy'><dt id='zDYZy'><q id='zDYZy'><span id='zDYZy'><b id='zDYZy'><form id='zDYZy'><ins id='zDYZy'></ins><ul id='zDYZy'></ul><sub id='zDYZy'></sub></form><legend id='zDYZy'></legend><bdo id='zDYZy'><pre id='zDYZy'><center id='zDYZy'></center></pre></bdo></b><th id='zDYZy'></th></span></q></dt></tr></i><div id='zDYZy'><tfoot id='zDYZy'></tfoot><dl id='zDYZy'><fieldset id='zDYZy'></fieldset></dl></div>
        • <bdo id='zDYZy'></bdo><ul id='zDYZy'></ul>
      1. 带有隐藏 UIView 的自动布局?

        时间:2023-09-11
          <bdo id='v1edx'></bdo><ul id='v1edx'></ul>

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

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

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

                  <tfoot id='v1edx'></tfoot>
                    <tbody id='v1edx'></tbody>
                1. 本文介绍了带有隐藏 UIView 的自动布局?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我觉得显示/隐藏 UIViews 是一种相当常见的范例,最常见的是 UILabels,具体取决于业务逻辑.我的问题是,使用 AutoLayout 响应隐藏视图的最佳方式是什么,就好像它们的框架是 0x0 一样.以下是 1-3 个功能的动态列表示例.

                  I feel like it's a fairly common paradigm to show/hide UIViews, most often UILabels, depending on business logic. My question is, what is the best way using AutoLayout to respond to hidden views as if their frame was 0x0. Here is an example of a dynamic list of 1-3 features.

                  现在我从按钮到最后一个标签有一个 10px 的顶部空间,当标签隐藏时显然不会向上滑动.截至目前,我为这个约束创建了一个出口,并根据我显示的标签数量来修改常量.这显然有点棘手,因为我使用负常数值将按钮向上推到隐藏帧上.这也很糟糕,因为它不受实际布局元素的限制,只是基于其他元素的已知高度/填充的偷偷摸摸的静态计算,并且显然与 AutoLayout 的构建目的作斗争.

                  Right now I have a 10px top space from the button to the last label, which obviously won't slide up when the the label is hidden. As of right now I created an outlet to this constraint and modifying the constant depending on how many labels I'm displaying. This is obviously a bit hacky since I'm using negative constant values to push the button up over the hidden frames. It's also bad because it's not being constrained to actual layout elements, just sneaky static calculations based on known heights/padding of other elements, and obviously fighting against what AutoLayout was built for.

                  显然,我可以根据我的动态标签创建新的约束,但是对于试图折叠一些空白来说,这是大量的微观管理和大量的冗长.有更好的方法吗?更改帧大小 0,0 并让 AutoLayout 在不操纵约束的情况下完成其工作?完全删除视图?

                  I could obviously just create new constraints depending on my dynamic labels, but that's a lot of micromanaging and a lot of verbosity for trying to just collapse some whitespace. Are there better approaches? Changing frame size 0,0 and letting AutoLayout do its thing with no manipulation of constraints? Removing views completely?

                  老实说,仅仅从隐藏视图的上下文中修改常量就需要一行代码和简单的计算.用 constraintWithItem:attribute:relatedBy:toItem:attribute:multiplier:constant: 重新创建新约束似乎很繁重.

                  Honestly though, just modifying the constant from context of the hidden view requires a single line of code with simple calculation. Recreating new constraints with constraintWithItem:attribute:relatedBy:toItem:attribute:multiplier:constant: seems so heavy.

                  2018 年 2 月编辑:使用 UIStackViews

                  推荐答案

                  UIStackView 可能是适用于 iOS 9+ 的方式.它不仅可以处理隐藏视图,如果设置正确,它还会移除额外的间距和边距.

                  UIStackView is probably the way to go for iOS 9+. Not only does it handle the hidden view, it will also remove additional spacing and margins if set up correctly.

                  这篇关于带有隐藏 UIView 的自动布局?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:Xcode 8 中的“Vary for Traits"是什么? 下一篇:使用自动布局,如何根据图像使 UIImageView 的大小动态变化?

                  相关文章

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

                    <legend id='fHQOh'><style id='fHQOh'><dir id='fHQOh'><q id='fHQOh'></q></dir></style></legend>
                    1. <small id='fHQOh'></small><noframes id='fHQOh'>

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