简体   繁体   English

滚动视图内的约束

[英]Constraints inside Scroll View

I'm working on application for iOS. 我正在为iOS应用程序工作。 Trying to use Autolayout with Scroll View . 尝试将自动布局与Scroll View一起使用。 But there is some problem. 但是有一些问题。 I have View -> Scroll View -> Content View hierarchy. 我有视图 -> 滚动视图 -> 内容视图层次结构。 I pinned (top, bottom, left, right) of the Scroll View to the Main View , and also pinned Content View to Scroll View . 我将Scroll View固定(顶部,底部,左侧,右侧)到主视图 ,还将Content View固定到Scroll View Then i've added imageView on the top of the screen and text label below, to the Content View . 然后,我在屏幕顶部添加了imageView,在下面添加了文本标签到Content View Added them constraints including vertical spacing (8pt) from image to label. 添加了这些约束,包括从图像到标签的垂直间距 (8pt)。 In Preview everything looks ok and label placed right below image, however when i'm running the app on iOS Simulator, my label places right in the middle of image. 在“预览”中,一切正常,标签位于图像的正下方,但是当我在iOS Simulator上运行应用程序时,我的标签正位于图像的中间。 Please, any help? 请帮忙吗?

We found an answer in the comments: it was due to a wrong content scaling mode of the image. 我们在评论中找到了答案:这是由于错误的图像内容缩放模式所致。 It needed to be ClipToBounds . 它必须是ClipToBounds

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

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