【问题标题】:Autolayout still shows error after I have set margins设置边距后自动布局仍然显示错误
【发布时间】:2018-11-20 23:52:58
【问题描述】:

我是 Swift 新手,最近开始学习 AutoLayout。看起来很直观,但我现在正在设计enter image description here 的东西,我不确定为什么会出现错误。您可以在下面的图片中看到更多信息,但本质上,我将滚动视图固定在侧面以及上下边缘。我还需要提供哪些信息?enter image description here

【问题讨论】:

  • 在文档大纲中向我们展示您的视图层次结构。

标签: swift uiscrollview autolayout


【解决方案1】:

您好,您必须先将 ContentView(UIView) 添加到 ScrollView。然后在该 ContentView 中添加您的其他组件。

  1. 将 ScrollView 拖到 UIViewController.Apply top,bottom.leading,trailing == 0
  2. 将 UIview(ContentView) 添加到 ScrollView。应用 top,bottom,leading,trailing == ScrollView(top,bottom,leading,trailing)
  3. 更重要的是:-将 ContentView 的等宽和等高应用到 ScrollView 父视图

更多详情:-https://medium.com/@pradeep_chauhan/how-to-configure-a-uiscrollview-with-auto-layout-in-interface-builder-218dcb4022d7

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2022-11-13
    • 2013-05-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多