在使用帧 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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

how to set scrollview content size in swift 3.0(如何在 swift 3.0 中设置滚动视图内容大小)
Stop a UITableView from automatically scrolling(阻止 UITableView 自动滚动)
iOS UIScrollView Lazy Loading(iOS UIScrollView 延迟加载)
using iOS 6.0 SDK and building for iOS 5 Target causes UIScrollView setMinimumZoomScale to fail when running on iOS 5 simulator(在 iOS 5 模拟器上运行时,使用 iOS 6.0 SDK 并为 iOS 5 Target 构建会导致 UIScrollView setMinimumZoomScale 失败) -
Create partial-screen UIPageViewController programmatically(以编程方式创建部分屏幕 UIPageViewController)
how to make an ImageView zoomable with or without ScrollView.?(如何使用或不使用 ScrollView 使 ImageView 可缩放?)