代码之家  ›  专栏  ›  技术社区  ›  Bilal hao zou

具有大小类的UIStackView子视图

  •  2
  • Bilal hao zou  · 技术社区  · 7 年前

    尝试使用大小类实现iStackView,iPhone有2个标签,iPad有3个标签。

    视图层次结构

    1. [UIStackView] 
        [UILabel 1] [UILabel2]
      [UIStackView] 
      

      enter image description here

    2. RxR尺寸等级

      [UIStackView] 
        [UILabel 1] [UILabel2] [UILabel3]
      [UIStackView] 
      

      enter image description here

    正如你在上面的屏幕截图中看到的那样,它在故事板中看起来和预期完全一样,但在模拟器iPad上的视图是混乱的。

    (好的)

    enter image description here

    iPad肖像输出 (一团糟)

    enter image description here

    iPad横向输出 (一团糟) enter image description here

    iPad上发生了什么??是虫子还是我错过了什么? 谢谢

    我创建了一个 sample project

    2 回复  |  直到 7 年前
        1
  •  2
  •   Ketan Parmar    7 年前

    按照以下步骤实现您的要求:

    • 将一个水平堆栈视图拖动到界面生成器中
    • 将其约束设置为: top,leading, =trailing and fixed height
    • 将三个标签拖放到其中,一起选择并设置一个约束: Equal width
    • 现在选择第二个或中间标签,然后从 attribute inspector 点击 + 旁边的按钮 installed uncheck the checkbox for that R,R variation . 请参阅下面的屏幕截图以更好地理解,

    enter image description here

    你完了!现在,你的中心标签将不会显示在iPad中,而每个标签都将显示在iPhone中!

    见以下结果截图 iphone and ipad 就我而言!

    苹果手机:

    enter image description here

    iPad:

    enter image description here

    更新:

    如果你想在iPhone中隐藏标签并在iPad中显示,那么再添加一个变体: Compact Width Regular Height 对于中间标签,取消选中要卸载的复选框。请参阅下面的屏幕截图,

    enter image description here

        2
  •  2
  •   rodskagg    7 年前

    似乎您正在使用Interface Builder中的“installed”(已安装)复选框隐藏iPhone上的一个标签。相反,使用“隐藏”复选框似乎可以解决问题。我想这是一个错误。