gpt4 book ai didi

ios - 屏幕宽度和高度

转载 作者:行者123 更新时间:2023-11-29 11:06:29 25 4
gpt4 key购买 nike

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

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

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

最佳答案

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

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

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

关于ios - 屏幕宽度和高度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13360182/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com