我有一个 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"中调整大小.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
如何使用或不使用 ScrollView 使 ImageView 可缩放?how to make an ImageView zoomable with or without ScrollView.?(如何使用或不使用 ScrollView 使 ImageView 可缩放?)
UIScrollView 只能用一根手指滚动UIScrollView scrolling only with one finger(UIScrollView 只能用一根手指滚动)
在 UIScrollView 中使用 UITouchUsing UITouch inside a UIScrollView(在 UIScrollView 中使用 UITouch)
UitextField resignFirstResponder 在滚动视图中不起作用UitextField resignFirstResponder does not work in scroll view(UitextField resignFirstResponder 在滚动视图中不起作用)
如何阻止 UIScrollView 吞下触摸How to Stop a UIScrollView from Swallowing Touches(如何阻止 UIScrollView 吞下触摸)
在滚动期间更改背景颜色Make background color change during scroll(在滚动期间更改背景颜色)