我使用以下代码来获取屏幕尺寸宽度:
CGFloat width = [UIScreen mainScreen].bounds.size.width - 100;
但其纵向和横向的宽度均为“668.0”。
如何根据设备的方向获得不同的宽度。
我遇到了与您相同的问题,我所能找到的就是检查方向并计算高度和宽度,如下所示:
UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];
screenHeight = orientation == UIInterfaceOrientationLandscapeLeft || orientation == UIInterfaceOrientationLandscapeRight ? 748 : 1004;
screenWidth = orientation == UIInterfaceOrientationLandscapeLeft || orientation == UIInterfaceOrientationLandscapeRight ? 1024 : 768;
这些尺寸显然适用于 iPad,但如果尺寸合适,它也适用于 iPhone。
我个人认为有点差,但我找不到其他东西。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)