我有一个 UIViewController 子类,它的视图在 NIB 文件中配置.该视图有一个 UIScrollView 子视图.
I have a UIViewController subclass whose view is configured in a NIB file. The view has a UIScrollView subview.
UIScrollView 几乎占据了它的整个 NIB 文件,但它的超级视图作为子视图添加到一个小得多的视图(配置在不同的 NIB 中)——例如UIScrollView 是它自己的 NIB 高度的 80%,但最终只有应用程序窗口高度的 10%.
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.
当我在 viewController 的 viewDidLoad 方法中调用 [scrollView bounds].size.height 时,我得到了 scrollView 相对于它自己的 NIB 的高度,而不是它最终调整为由其超级视图指定的高度(例如 80窗口高度的 % 而不是 10%).
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%).
如果我稍后调用 [scrollView bounds].size.height(例如处理旋转事件),我会得到正确的值.
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?
你试过用 viewWillAppear:
或 viewDidAppear
处理吗?
Have you tried dealing with it in viewWillAppear:
or viewDidAppear
?
这篇关于UIScrollView 边界尚未在“viewDidLoad"中调整大小.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!