UIScrollView bounds have not yet resized in quot;viewDidLoadquot;(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"中调整大小.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:UIScrollView 边界尚未在“viewDidLoad"中调整大小
基础教程推荐
- Android:对话框关闭而不调用关闭 2022-01-01
- 在 gmail 中为 ios 应用程序检索朋友的朋友 2022-01-01
- Kivy Buildozer 无法构建 apk,命令失败:./distribute.sh -m “kivy"d 2022-01-01
- 当从同一个组件调用时,两个 IBAction 触发的顺序是什么? 2022-01-01
- 如何在 UIImageView 中异步加载图像? 2022-01-01
- UIWebView 委托方法 shouldStartLoadWithRequest:在 WKWebView 中等效? 2022-01-01
- 如何让对象对 Cocos2D 中的触摸做出反应? 2022-01-01
- 如何在 iPhone 上显示来自 API 的 HTML 文本? 2022-01-01
- 如何在没有IB的情况下将2个按钮添加到右侧的UINavigationbar? 2022-01-01
- android 应用程序已发布,但在 google play 中找不到 2022-01-01