如何适应iPhone 4的屏幕分辨率? [英] How to accommodate for the iPhone 4 screen resolution?

查看:140
本文介绍了如何适应iPhone 4的屏幕分辨率?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据 Apple ,iPhone 4有一个新的更好的屏幕分辨率:

According to Apple, the iPhone 4 has a new and better screen resolution:


3.5英寸(对角线)宽屏多点触控显示器

960×640像素分辨率326 ppi

3.5-inch (diagonal) widescreen Multi-Touch display
960-by-640-pixel resolution at 326 ppi

这个小细节会影响我们的应用程序。网上的大多数演示应用程序都有一个共同点:他们认为屏幕的固定大小为320 x 480像素。因此,大多数(如果不是全部)开发人员所做的是:他们以这样的方式设计所有东西,可触摸区域(例如)50 x 50像素大。足以点击它。事情已经相对于左上角定位,以达到屏幕上的特定位置 - 让我们说中心,或者在底部的某个位置。

This little detail affects our apps in a heavy way. Most of the demo apps on the net have one thing in common: They position views in the believe that the screen has a fixed size of 320 x 480 pixels. So what most (if not all) developers do is: they designed everything in such a way, that a touchable area is (for example) 50 x 50 pixels big. Just enough to tap it. Things have been positioned relative to the upper left, to reach a specific position on screen - let's say the center, or somewhere at the bottom.

当我们开发高分辨率时应用程序,它们可能无法在旧设备上运行。如果他们这样做,他们将遭受4倍于任何图像大小的痛苦,不得不在内存中缩小它们。

When we develop high-resolution apps, they probably won't work on older devices. And if they do, they would suffer a lot from 4-times the size of any image, having to scale them down in memory.

推荐答案

根据 支持高 - 视图中的分辨率屏幕 ,来自Apple文档:

According to Supporting High-Resolution Screens In Views, from the Apple docs:


在具有高分辨率屏幕的设备上, imageNamed:
imageWithContentsOfFile:
initWithContentsOfFile:方法
在名称中使用 @ 2x
修饰符自动查找所需图像的
版本。如果找到一个,
它会加载该图像。如果您执行
不提供给定图像的高分辨率版本
,则图像对象
仍会加载标准分辨率
图像(如果存在)并将其缩放$在绘图期间b $ b。

On devices with high-resolution screens, the imageNamed:, imageWithContentsOfFile:, and initWithContentsOfFile: methods automatically looks for a version of the requested image with the @2x modifier in its name. It if finds one, it loads that image instead. If you do not provide a high-resolution version of a given image, the image object still loads a standard-resolution image (if one exists) and scales it during drawing.

当它加载图像时,UIImage对象会自动将大小和
比例属性设置为适当的值
基于图像文件的后缀。
对于标准分辨率图像,
将scale属性设置为1.0,
将图像的大小设置为
图像的像素尺寸。对于带有文件名中@ 2x后缀的图像

它将scale属性设置为2.0,
将宽度和高度值减半,以
补偿比例因子。这些
减半的值正确地与
相关联,你需要在逻辑坐标空间中使用
渲染图像的
所需的基于点的尺寸。

When it loads an image, a UIImage object automatically sets the size and scale properties to appropriate values based on the suffix of the image file. For standard resolution images, it sets the scale property to 1.0 and sets the size of the image to the image’s pixel dimensions. For images with the @2x suffix in the filename, it sets the scale property to 2.0 and halves the width and height values to compensate for the scale factor. These halved values correlate correctly to the point-based dimensions you need to use in the logical coordinate space to render the image.

这篇关于如何适应iPhone 4的屏幕分辨率?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆