ios 如何获取iOS设备屏幕高度和宽度
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14135207/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to get iOS device screen height and width
提问by colindunn
Possible Duplicate:
IPhone/IPad: How to get screen width programmatically?
How to get orientation-dependent height and width of the screen?
Accounting for the various iOS devices and orientations, what is the simplest approach to getting the current screen resolution, including height and width?
考虑到各种 iOS 设备和方向,获取当前屏幕分辨率(包括高度和宽度)的最简单方法是什么?
回答by Srikar Appalaraju
回答by P.J
CGRect screenBounds = [[UIScreen mainScreen] bounds];
That will give you the entire screen's resolution in points, so it would most typically be 320x480 for iPhones. Even though the iPhone4 has a much larger screen size iOS still gives back 320x480 instead of 640x960. This is mostly because of older applications breaking.
这将为您提供整个屏幕的分辨率(以点为单位),因此对于 iPhone,它通常为 320x480。即使 iPhone4 有更大的屏幕尺寸,iOS 仍然返回 320x480 而不是 640x960。这主要是因为较旧的应用程序中断。
Hope it helps you..
希望能帮到你。。