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

2022-12-31移动开发问题
5

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

The End

相关推荐

硬件音量按钮更改应用程序音量
Hardware Volume buttons change in app volume(硬件音量按钮更改应用程序音量)...
2024-08-12 移动开发问题
10

Cocos2d - 如何检查不同层中对象之间的交集
Cocos2d - How to check for Intersection between objects in different layers(Cocos2d - 如何检查不同层中对象之间的交集)...
2024-08-12 移动开发问题
8

恢复游戏 cocos2d
Resume game cocos2d(恢复游戏 cocos2d)...
2024-08-12 移动开发问题
6

Cocos2D + 仅禁用 Retina iPad 图形
Cocos2D + Disabling only Retina iPad Graphics(Cocos2D + 仅禁用 Retina iPad 图形)...
2024-08-12 移动开发问题
10

如何将 32 位 PNG 转换为 RGB565?
How to convert 32 bit PNG to RGB565?(如何将 32 位 PNG 转换为 RGB565?)...
2024-08-12 移动开发问题
21

正确的 cocos2d 场景重启?
Proper cocos2d scene restart?(正确的 cocos2d 场景重启?)...
2024-08-12 移动开发问题
7