简体   繁体   English

Xcode Scrollview错误约束

[英]Xcode Scrollview wrong constraints

I designed a UI in Xcode with a ScrollView and added constraints to it. 我在Xcode中使用ScrollView设计了一个UI,并为其添加了约束。 In Interface designer it looks as I want, but running it with the simulator causes a big spacing at the right side of the ContentView inside the ScrollView. 在Interface Designer中,它看起来像我想要的,但是使用模拟器运行它会导致ScrollView内部ContentView的右侧有很大的间距。

Here are two pics to show what I mean 这是两个图片,以显示我的意思

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

So what did I do wrong here? 那么,我在这里做错了什么?

Thanks for your helping hand 谢谢你的帮忙

Solution

The ContentView needed the same width than the View. ContentView需要与View相同的宽度。 So select both, go to your constraints and select "Equal Widths". 因此,选择两者,转到您的约束条件,然后选择“相等宽度”。

在我看来,您似乎尚未向滚动视图(ScrollViewer)添加约束以将其边缘固定到其父视图(View)。

I had this same issue after updating to xcode 8+. 更新到xcode 8+之后,我遇到了同样的问题。 ScrollView started to act strange. ScrollView开始表现奇怪。 For now I am adding constrains from inside scrollView to another view witch isn't in scrollView itself (like leading, trailing) to mainView. 现在,我将约束从scrollView内添加到另一个视图,而scrollView本身不在主视图内(例如前导,尾随)。

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

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