在情节提要中创建的ScrollView初始化为框架0,0,0,0 [英] ScrollView created in storyboard initialized with frame 0,0,0,0

查看:91
本文介绍了在情节提要中创建的ScrollView初始化为框架0,0,0,0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在情节提要中创建了一个UIScrollView,并将其作为属性链接到视图控制器,现在正尝试通过分页添加一些子视图.但是,即使我以图形方式在情节提要中设置了尺寸,UIScrollView的框架最终还是0,0,0,0.即使我已在情节提要中以图形方式指定了尺寸,我是否仍需要对尺寸进行硬编码?

I created a UIScrollView in the storyboard, linked it as a property to the view controller, and am now trying to add some subviews with pagination. But, even though I set the dimensions in the storyboard graphically, the frame of the UIScrollView ends up being 0,0,0,0. Am I required to hardcode the dimensions even though I already specified them graphically in the storyboard?

与此相关,是否可以在情节提要中自定义子视图以在此滚动视图中使用?似乎我无法创建这样的视图,除非它已经在控制器中.由于我只有一个控制器,并且可能要以图形方式设置多个视图,因此该如何执行而不必以编程方式进行设置?

Also, kind of related, is it possible to customize subviews in the storyboard to use in this scroll view? It seems that I cannot create such a view unless it is already within a controller. Since I only have one controller and potentially multiple views I want to set up graphically, how do I do this without having to do so programmatically?

推荐答案

使用情节提要板 viewDidLayoutSubviews 是获取所有视图大小的地方. viewWillAppear 不适用于我,并且始终返回(0,0,0,0);

With storyboards viewDidLayoutSubviews is where you can get the size of all your views. viewWillAppear did not work for me and always returned (0,0,0,0);

这篇关于在情节提要中创建的ScrollView初始化为框架0,0,0,0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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