UIScrollView边界尚未在“viewDidLoad”中调整大小。 [英] UIScrollView bounds have not yet resized in "viewDidLoad"
问题描述
我有一个UIViewController子类,其视图在NIB文件中配置。该视图有一个UIScrollView子视图。
UIScrollView几乎占用了整个NIB文件,但它的superview作为子视图添加到一个更小的视图(配置在不同的NIB ) - 例如UIScrollView是它自己的NIB的高度的80%,但最终只有应用程序的窗口的高度的10%。
当我调用[scrollView bounds] .size。 height在viewController的viewDidLoad方法中,我得到了scrollView相对于它自己的NIB的高度,而不是它的高度,它调整大小到它的superviews指定的(例如窗口的高度的80%,而不是10%)。 p>
如果我稍后调用[scrollView bounds] .size.height(例如处理旋转事件),我得到正确的值。
如何获得最初正确调整大小的值?
viewWillAppear:
或 viewDidAppear
?
I have a UIViewController subclass whose view is configured in a NIB file. The view has a UIScrollView subview.
The UIScrollView takes up almost its entire NIB file but it's superview is added as a subview to a much smaller view (configured in a different NIB) - e.g. the UIScrollView is 80% the height of it's own NIB but ends up only being 10% the height of the application's window.
When I call [scrollView bounds].size.height in the viewController's viewDidLoad method, I get the height of the scrollView relative to it's own NIB, rather than the height it ends up resizing to as dictated by its superviews (e.g. 80% of the window's height rather than 10%).
If I call [scrollView bounds].size.height later on (e.g. to handle a rotation event), I get the correct value.
How can I get the correctly re-sized value initially?
Have you tried dealing with it in viewWillAppear:
or viewDidAppear
?
这篇关于UIScrollView边界尚未在“viewDidLoad”中调整大小。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!