iphone开发之分辨率问题

1. [UIScreen mainScreen].applicationFrame 是{(0,20),(320,460)}

UIScreen mainScreen].bounds 是{(0,0),(320,480)}

CGSize size = [UIScreen mainScreen].currentMode.size;//以像素为单位的尺寸

give measurements in "points", not "pixels". For everything else, pixels=points, but for the iPhone4, each point has 4 pixels. Normal images are scaled in the iPhone4, so each pixel in the image is mapped onto a point. This means that the iPhone4 can run iPhone apps without a noticeable change.

iPhone是以“点”来计量尺寸,而不是像素。一般情况,一个点 = 一个像素,但是iPhone4一个点等于4个像素,所以用[[UIScreen mainScreen] applicationFrame].size.width取出来的长度和宽度还是320*480.这也意味着iPhone4跑以前的程序基本不用做修改。

The "apple" way to add "hi-res" images that take advantage of the iPhone's greater resolution is to replace ".png" with "@2x.png" in the image file name, and double the pixel density (effectively, just the width&height) in the image. Importantly, don't change the way the image is referred to in your code.
So if you have "img.png" in your code, iPhone4 will load the "[email protected]" image if it is available.

但是之前有涉及到图片的,一个像素被拉伸到了4个像素,图片质量会变低。解决方法是替换图片的后缀为 "@2x.png",代码中的引用不用做任何改变,系统会根据硬件自动去读入相关文件。

The problem with this is that, if you are trying to develop a Universal app, and include separate images for all the different possible screen resolutions/pixel densities, your app will get bloated pretty quick.

这样解决问题的缺点是,当你有很多图片的时候,你的程序包会有增加得很大块。

A common solution to this problem is to pull all the required images on the net. This will make your binary nice and small. On the negative side, this will eat into your user's internet quota, and it will really annoy users who don't have wifi--especially if your app has no other reason to use the 'net (and you don't say your app needs the 'net in your app store description).

对于此问题一般的解决方法是将图片放到网上,运行程序时获取。当时这样也会涉及到用户上网和流量的问题。

http://blog.sina.com.cn/s/blog_4cdc44df0100phfr.html

2.在ios工程中的代码中,只需要使用不带@2x的图片名。

使用iphone retina模拟器时,如果工程中把640x960像素(简称640)的图片写成了不带@2x,则模拟器会认为这是一张320x480像素(简称320)的图片,采用1对1(1个像素对应1个点)的策略,,只显示其左上320x480像素即1/4的部分.

使用iphone模拟器时,如果使用了640的@2x图片,同样会正常显示,因为模拟器会把图片中的4个像素对应为一个点; 如果把320的图片写成了@2x,页面中的背景图片会完全显示到屏幕左上部分,因为此时按4对1,图片只够显示在屏幕左上。不过启动图片仍然全屏,但会变的模糊,。

只有iphone4会区分识别@2x, iphone3不会识别@2x,但640x960的Default.png能正常缩放显示。其它的640x960的图片只能显示1/4。

iPhone4支持的屏也叫视网膜(retina)屏,就是肉眼看不到像素点。

可能内存不足的时候,如果已有很多retina的程序跑于后台, 会加载normal的,以节约内存。

在升级到ios4的iPhone3上,优先使用不带@2x的图片。

3.关于UIImage.size属性

In iOS 3.x and earlier, this value always reflects the dimensions of the image measured in pixels.

In iOS 4.0 and later, this value reflects the logical size of the image and is measured in points.

4.关于iPhone默认启动图片Default.png

可以提供为屏幕尺寸,也可以提供为屏幕尺寸减去状态栏尺寸.

对于iphone, Default.png可以为320x480或者320x460, [email protected] iPhone4启动图片640x960或者640x920.

http://news.wangmeng.cn/detailNews/2984-iphone-start-page-default-png

标准: .
高分辨率: @2x.
device_modifier:可选, ~ipad or ~iphone.

UIImage的imageNamed:, imageWithContentsOfFile:, and initWithContentsOfFile: 这3个方法有自动选择高清图片的效果

plist中的CFBundleIconFiles 属性

icon尺寸
iphone
57 x 57 pixels
114 x 114 pixels (@2x)
搜索结果中的额图标
29 x 29 pixels
58 x 58 pixels (@2x)

iPad
72 x 72 pixels
搜索结果中的额图标
50 x 50 pixels

启动画面
iphone
320 x 480 pixels
640 x 960 pixels (high resolution)

ipad
768 x 1004 pixels

可能Icon.png,[email protected]也要大写i。

纵向状态下:

状态栏20高,导航栏44高,选项卡或工具栏48高,键盘216高,UISwitch94x28,分段控件44高,输入框30高。

类方法用来隐藏间例。

关于app同时支持iphone/ipad的问题

http://www.cocoachina.com/bbs/read.php?tid-44651.html

http://www.cocoachina.com/bbs/read.php?tid-41245-keyword-xib%7C%CE%C4%BC%FE.html

http://www.cocoachina.com/bbs/read.php?tid-31022.html

iPhone与iPad开发的区别

http://blog.csdn.net/favormm/article/details/6551849

Sizes of iPhone UI Elements

http://www.idev101.com/code/User_Interface/sizes.html

thx:http://www.buerguo.com/archives/991

猜你喜欢

转载自justsee.iteye.com/blog/1628948