从iOS 8开始,屏幕边界假设取决于方向。但当我在iOS 9.1中打印值时,更改模拟器的方向-它们保持不变!
let h = UIScreen.mainScreen().bounds.height
let w = UIScreen.mainScreen().bounds.width
dbpr("orient: (devOrient.rawValue) w: (w), h: (h)")
//the above prints this:
orient: 1 w: 320.0, h: 548.0
orient: 3 w: 320.0, h: 548.0
orient: 2 w: 320.0, h: 548.0
orient: 4 w: 320.0, h: 548.0
重新安装Xcode没有帮助。你知道发生了什么事吗?
原来原因是我将"目标/常规"下的"设备方向"设置为"仅纵向"。