问题描述
我在情节提要中创建了一个 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);
这篇关于在使用帧 0,0,0,0 初始化的故事板中创建的 ScrollView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!