UIScrollView和自动布局不起作用

亚历山德罗·加塞兹(Alessandro Garcez)

我正在尝试使视图在我的应用中可滚动。

O完全按照教程https://www.youtube.com/watch?v=UnQsFlMGDsI中的步骤进行操作

我所做的主要步骤是:

  • 添加一个UIscrollView
  • 将视图添加到UIscrollView(内容视图)
  • 为UIScrollView创建值0(上,左,右和botton)的边距约束
  • 为“内容”视图创建值为0(上,左,右和波顿)的边距约束
  • 在ContentView和主视图之间创建2个“等宽”和“等高”约束
  • ...(添加一些文本字段)

当我运行应用程序时,scrollView不起作用

在此处输入图片说明

I really can't make it work. I tried many ways to apply a UIScrollView and didn't get it.

Sreejith

As mentioned in the video, the main aim is to automatically adjust the UIScrollView contentSize to the size of the screen or to the size of the content in such way that on smaller devices scrolling is active and on larger devices scrolling is not active because it is not needed.

For this to achieve you've to set proper constraints to the content view so that the height is automatically calculated. From your video its visible that you're not setting the proper constraint to the last UITextFeild (this is important).

您必须在最后一个约束中赋予顶部底部 约束UITextField以便自动计算contentView的高度

我已经完成了一个示例项目,您可以在此处查看:
示例项目

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章