2013-02-23 128 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'); 
}