在使用帧 0,0,0,0 初始化的故事板中创建的 ScrollView

ScrollView created in storyboard initialized with frame 0,0,0,0(在使用帧 0,0,0,0 初始化的故事板中创建的 ScrollView)
本文介绍了在使用帧 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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

相关文档推荐

Hardware Volume buttons change in app volume(硬件音量按钮更改应用程序音量)
Resume game cocos2d(恢复游戏 cocos2d)
Cocos2D + Disabling only Retina iPad Graphics(Cocos2D + 仅禁用 Retina iPad 图形)
[ios.cocos2d+box2d]how to disable auto-rotation?([ios.cocos2d+box2d]如何禁用自动旋转?)
Storing and reading files from Documents directory iOS 5(从 Documents 目录存储和读取文件 iOS 5)
How can I implement a virtual joystick for a cocos2d game outside the cocos2d environment?(如何在 cocos2d 环境之外实现 cocos2d 游戏的虚拟摇杆?)