【问题标题】:Screen width and height屏幕宽度和高度
【发布时间】:2012-11-01 20:22:16
【问题描述】:

我想用这段代码获取屏幕的宽度和高度...

float screenWidth = [UIScreen mainScreen].bounds.size.width;
float screenHeight = [UIScreen mainScreen].bounds.size.height;
NSLog(@"%f %f",screenWidth, screenHeight);

我总是得到 320 480 ,但这些不是模拟器的真正衡量标准。现在我在分辨率更高的视网膜模拟器上进行测试,但我总是得到 320 480

【问题讨论】:

  • 如果对你有帮助,你应该接受答案。

标签: ios height width resolution measure


【解决方案1】:

我想你的答案可以在这里找到:in iPhone App How to detect the screen resolution of the device

这也是您感兴趣的规模。使用CGFloat screenScale = [[UIScreen mainScreen] scale];找出比例。

定位元素时,您的点应始终采用非视网膜比例。 3.5 英寸的屏幕尺寸为 320x480 单位,4 英寸屏幕的尺寸为 320x568。像素分辨率是视网膜屏幕的两倍。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-09-09
    • 1970-01-01
    • 2010-11-25
    • 2015-09-10
    • 2017-06-17
    • 2011-09-25
    • 2021-10-25
    相关资源
    最近更新 更多