【发布时间】:2014-07-29 18:54:12
【问题描述】:
我在为我的一个视图设置框架时遇到问题。我知道 iPhone 5 的高度是 568,但是当我将此代码输入到 ViewController 中的viewDidLoad 时:
var height = self.bounds.height
println(height)
输出:
640.0
为什么应该是 568 却是这个样子?是模拟器的问题吗?
【问题讨论】:
-
改用 self.view.bounds.height
-
我认为您必须将该代码放在 viewWillAppear 中,因为视图的框架直到那时才更新。
-
哎呀,我的意思是 self.view.bounds.size.height