iPhone和iPad屏幕分辨率

时间:2013-02-23 05:26:13

标签: iphone ipad

我正在开发一个通用的应用程序。我想知道iPad的屏幕分辨率(320 * 480)和iPad的(768 * 1024)将适用于所有iphone(iPhone 3g,iPhone4等)和所有iPad。因为基于这些屏幕分辨率,我设置了textField,UILabel在iPhone和iPad上的宽度。这些工作适用于视网膜和nonretinas吗?

3 个答案:

答案 0 :(得分:15)

Retina iPhone和iPad使用与非Retina设备相同的坐标系。目前,所有iPad的逻辑坐标空间为768x1024,除iPhone 5外的所有iPhone都具有320x480的逻辑坐标空间。您的代码应该在Retina和非Retina设备上正常工作。

在iPhone 5上,您的应用程序将在屏幕顶部显示黑条,除非您通过为扩展屏幕分辨率包含Default.png告诉iOS您要使用全屏。

您可以使用[[UIScreen mainScreen] bounds]检查屏幕分辨率。这个值在Retina和非Retina设备上是相同的。您可以通过检查[[UIScreen mainScreen] scale]的值来检测Retina设备;这里的值是每单位逻辑坐标空间的物理像素数(非Retina为1.0,Retina为2.0)。

答案 1 :(得分:1)

UIKitCoreGraphics使用点而不是像素。

视网膜和非视网膜设备具有相同数量的点,但具有不同数量的像素。这意味着相同的点值可能意味着不同设备上的不同像素值。

要回答您的问题,是的,相同的布局UILabel宽度将在视网膜和非视网膜设备上显示相同。

来自Apple Developer Documentation:

In iOS, all coordinate values and distances are specified using floating-point values in units referred to as points. The measurable size of a point varies from device to device and is largely irrelevant. The main thing to understand about points is that they provide a fixed frame of reference for drawing.

查看“查看编程指南”中的“点与像素”部分: http://developer.apple.com/library/ios/documentation/windowsviews/conceptual/viewpg_iphoneos/WindowsandViews/WindowsandViews.html#//apple_ref/doc/uid/TP40009503-CH2-SW15

答案 2 :(得分:-1)

您始终可以使用这些功能来获取操作系统并完成界面所需的操作。

var pattern:RegExp = /iphone5/i; 
var str:String = Capabilities.os; 

if (str.search(pattern)==0)
{
    trace('iPhone5 Detected. Alter height.');
}else{
   trace('No need to change dimensions if developing at 960x640');
}
相关问题