gpt4 book ai didi

ios - UIView 在设置宽度等于 scrollview 时忽略了我的约束?

转载 作者:行者123 更新时间:2023-11-28 20:53:59 25 4
gpt4 key购买 nike

每次我将 View 的宽度设置为 ScrollView 时,它都会将绿色方 block 推离屏幕。

enter image description here

最佳答案

@belgrim 我在使用 ScrollView 时遇到了困难。我想分享我的工作。

  1. 首先,将 ScrollView 拖到您的 Storyboard 中并固定到四个边。

enter image description here

  1. 然后,在 ScrollView 中添加一个 View 并将其固定到其父 View (即 ScrollView )的四个边

enter image description here

  1. 结果应该是这样的

enter image description here(不要担心红色标记,这些将在接下来的步骤中修复)

  1. 添加一个约束,使 View 的宽度等于其父 View ( ScrollView )的宽度

enter image description here

结果如下:

enter image description here

  1. 现在,最重要的部分是,我们需要在 View 中添加我们的内容,并且应该在 View 中正确定义 y 约束,以便 ScrollView 根据内容滚动。在这里,我简单地添加一个标签并将约束定义为:

enter image description here

(此外,我将行数设置为0,换行符设置为自动换行)

最后,我们得到了正确定义的 Storyboard:

enter image description here

在标 checkout 口中定义了长文本,我们得到的最终输出:

enter image description here

我展示了一个添加标签的简单示例,您可以根据需要添加其他 View ,只要确保您不会错过定义 y 约束即可。

希望这对您有所帮助。

关于ios - UIView 在设置宽度等于 scrollview 时忽略了我的约束?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54621361/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com