简体   繁体   English

滚动视图顶部间距

[英]Scroll view top spacing

I am very new to Auto Layout and generally iOS development. 我对自动布局和iOS开发非常陌生。 I have been struggling with the Top Space of my ScrollView for quite a while and I cannot figure out what causes it. 我已经在ScrollView的“顶部空间”中苦苦挣扎了很长时间,但我不知道是什么原因造成的。

在此处输入图片说明

The red container is the ScrollView and the grey container is a view encapsulating several views (label, picker view and text field). 红色容器是ScrollView,灰色容器是封装多个视图(标签,选择器视图和文本字段)的视图。

The desired result is that the grey container starts totally from the top. 理想的结果是灰色容器完全从顶部开始。

This is how my layout and constraints look like: 这是我的布局和约束的样子:

在此处输入图片说明

Any ideas will be much appreciated! 任何想法将不胜感激!

Ok, so your scroll view warning for ambiguous content height was causing the issue. 好的,因此您的滚动视图警告内容高度不明确导致了此问题。

I was able to resolve your issue by adding your scroll view inside a another view and adding missing constraints. 通过将滚动视图添加到另一个视图中并添加缺少的约束,我能够解决您的问题。 For reference: UIScrollView Scrollable Content Size Ambiguity . 供参考: UIScrollView Scrollable Content Size Ambiguity

My changes did make some issues to your margins etc, but you can fix them based on your need. 我的更改确实给您的利润等带来了一些问题,但是您可以根据需要进行修复。 Please let me know if this resolves your issue. 如果这可以解决您的问题,请告诉我。

Screenshots for your reference: 屏幕截图供您参考:

在此处输入图片说明 在此处输入图片说明

EDIT: Added screenshot for constraints of the wrapper view as well. 编辑:添加了屏幕快照的包装视图的约束以及。

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM