2013-02-23 126 views
5

我为开发一个通用app.I想知道将屏幕分辨率(320 * 480)的iPhone和(768 * 1024)的iPad将所有iPhone的(iPhone 3G,iPhone4的等)工作和所有的iPad。因为基于这些屏幕分辨率我设置textField的,UILabel的宽度在iPhone和iPad.Will这些工作视网膜和nonretinas?iPhone和iPad的屏幕分辨率

回答

15

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

上的iPhone 5,你的应用程序将在屏幕顶部黑条显示,除非你告诉别人你想包括为Default.png用于扩展屏幕分辨率使用全屏幕的iOS。

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

+0

是的,我已经把为iPad相同的768×1024分辨率320x480和(适用于iPhone)。它意味着iPhone5的左右没有其他cordinates视网膜和nonretina .Does使其在方向(纵向和横向)的区别?还有什么?应该我再次更改代码的规格? – 2013-02-23 05:33:39

+1

这里有很多不同的问题。我建议你先阅读关于UIViewController的Apple文档:http://developer.apple.com/library/ios/#documentation/uikit/reference/UIViewController_Class/Reference/Reference.html,其中涵盖了许多这些主题。 – 2013-02-23 05:38:19

1

UIKitCoreGraphics用点而不是像素的工作。

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

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

从苹果开发者文档:

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

-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'); 
}