使用UIScrollView自动布局 [英] Autolayout with UIScrollView

查看:74
本文介绍了使用UIScrollView自动布局的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Xcode中使用自动布局,并正在使用uiscrollview创建一个相当高(1300px)的ViewController来上下导航.我将viewcontroller设为自由格式,因此其尺寸为[375,1300].然后,我合并了滚动视图,添加了内容视图以及所有子视图和约束一切,没有约束错误.在运行时没有错误,但是当我希望它很高(〜1300px)且可滚动时,所有内容都被塞进了正常的屏幕尺寸.关于我在做什么错的任何线索吗?

I am using autolayout in Xcode and am creating a fairly tall (1300px) ViewController with a uiscrollview to navigate up and down. I made the viewcontroller freeform so its dimensions are [375,1300]. I then incorporated the scrollview, added the content view as well as all the subviews & constrained everything, leaving no constraint errors. At runtime there are no errors, but everything is all smushed into the normal screen size when I intended for it to be very tall (~1300px) and scrollable. Any clue as to what I am doing wrong?

下图显示了该问题,其中:

Below is a diagram showing the issue where:

  1. 外部Black Blox是ViewController的视图

  1. The Outer Black Blox is the ViewController's view

内部黑匣子是子视图

和蓝框"是屏幕上显示的内容

and The Blue Box is what is displayed on the screen

推荐答案

是的,您正确的@Ryan Cocuzzo.我认为您需要将子视图的优先级设置为1000到250.请参见下面的屏幕截图.

Yes, your correct @Ryan Cocuzzo. I think you need to set sub view priority from 1000 to 250. See below screen shots.

1)选择子视图的高度约束

1) Select height constraint of the subview

2)然后显示给尺寸检查器

2)Then go to show to size inspector

3)现在将优先级约束从1000更改为250.

3) Now change the priority constraint from 1000 to 250.

4)最后,您会得到这样的声音

4)Finally you get like this

这篇关于使用UIScrollView自动布局的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆