简体   繁体   中英

iPhone and iPad screen resolution

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

Retina iPhones and iPads use the same coordinate system as non-Retina devices. Presently all iPads have a logical coordinate space of 768x1024, and all iPhones except the iPhone 5 have a logical coordinate space of 320x480. Your code should work fine on both Retina and non-Retina devices.

On an iPhone 5, your app will be shown with black bars at the top of the screen unless you tell iOS that you want to use the full screen by including a Default.png for the extended screen resolution.

You can check the screen resolution with [[UIScreen mainScreen] bounds] . This value will be the same on Retina and non-Retina devices. You can detect a Retina device by checking the value of [[UIScreen mainScreen] scale] ; the value here is the number of physical pixels per unit of logical coordinate space (1.0 for non-Retina, 2.0 for Retina).

UIKit and CoreGraphics work with points rather than pixels.

Both the retina and non-retina devices have the same number of points, but a different amount of pixels. This means that the same point values can mean a different pixel value on different devices.

To answer your question, yes the same layout UILabel widths will display the same on retina and non retina devices.

From the 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.

Have a look at the Points vs. Pixels section in the View Programming Guide: http://developer.apple.com/library/ios/documentation/windowsviews/conceptual/viewpg_iphoneos/WindowsandViews/WindowsandViews.html#//apple_ref/doc/uid/TP40009503-CH2-SW15

You can always use the capabilities to get the OS and do what you need to your interface.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM