UIScrollView 边界尚未在“viewDidLoad"中调整大小.

UIScrollView bounds have not yet resized in quot;viewDidLoadquot;(UIScrollView 边界尚未在“viewDidLoad中调整大小.)
本文介绍了UIScrollView 边界尚未在“viewDidLoad"中调整大小.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

我有一个 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"中调整大小.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

相关文档推荐

NSString intValue not working for retrieving phone number(NSString intValue 不能用于检索电话号码)
Comparing in objective C - Implicit conversion of #39;int#39; to #39;id#39; is disallowed with ARC(在目标 C 中进行比较 - ARC 不允许将“int隐式转换为“id)
how can i pass an int value through a selector method?(如何通过选择器方法传递 int 值?)
Check if object is Class type(检查对象是否为类类型)
UIScrollView scroll not working after pushed with a navigation controller(使用导航控制器推送后 UIScrollView 滚动不起作用)
iOS setContentOffset not working on ipad(iOS setContentOffset 在 ipad 上不起作用)