ScrollView created in storyboard initialized with frame 0,0,0,0(在使用帧 0,0,0,0 初始化的故事板中创建的 ScrollView)
问题描述
我在情节提要中创建了一个 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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在使用帧 0,0,0,0 初始化的故事板中创建的 Scroll


基础教程推荐
- navigator.geolocation.getCurrentPosition 在 Android 浏览器上 2022-01-01
- Android:getLastKnownLocation(LocationManager.NETWORK_PROVIDER 2022-01-01
- 通过重定向链接在 Google Play 中打开应用 2022-01-01
- AdMob 广告未在模拟器中显示 2022-01-01
- iOS4 创建后台定时器 2022-01-01
- libGDX 从精灵或纹理中获取像素颜色 2022-01-01
- NSString intValue 不能用于检索电话号码 2022-01-01
- iPhone - 获取给定地点/时区的当前日期和时间并将其与同一地点的另一个日期/时间进行比较的正确方法 2022-01-01
- 如何从 logcat 中删除旧数据? 2022-01-01
- Cocos2d iPhone 非矩形精灵触摸检测 2022-01-01