0

查看截图

当我使用 self.view.frame.size.height 时,它会获取子笔尖的高度,而不是视图如何适应整体布局的高度。我使用 self.view.bounds.size.height 和 super.view.bounds.size.height 得到相同的值。

任何帮助,将不胜感激。

4

2 回答 2

2

在正确的时间询问。直到视图准备好出现,iOS 才知道它的实际大小。将取决于正确大小的视图的代码移动到viewWillAppear而不是方法viewDidLoadinit方法。

于 2011-10-28T19:22:56.507 回答
0

In Xcode 4 you would select your view controller that contains the UIScrollView and set the 'Simulated Metrics' in the IB Attributes Inspector as follows:

Attributes Inspector

This ensures that your UIScrollView will be set to the correct size to fill the available space at design time. It looks like you are using an older version of Xcode/IB and I can't remember exactly where these settings used to be but they're in there somewhere.

With the layout designed to accommodate the space taken up by the tab bar you should be able to query the size of the UIScrollView at any time and get the correct values.

于 2011-10-28T19:14:11.060 回答