如何适配iPhone 4屏幕分辨率?
根据 Apple 的说法,iPhone 4 拥有新的、更好的屏幕分辨率:
3.5 英寸(对角线)宽屏多点触控显示屏
960 x 640 像素分辨率,326 ppi
这个小细节对我们的应用程序影响很大。网络上的大多数演示应用程序都有一个共同点:它们认为屏幕具有 320 x 480 像素的固定尺寸来定位视图。因此,大多数(如果不是全部)开发人员所做的是:他们以这样的方式设计所有内容,可触摸区域的大小(例如)为 50 x 50 像素。只要敲一下就够了。事物已相对于左上角定位,以到达屏幕上的特定位置 - 比如说中心或底部的某个位置。
当我们开发高分辨率应用程序时,它们可能无法在旧设备上运行。如果他们这样做,他们将因任何图像大小为 4 倍而遭受很大损失,必须在内存中缩小它们。
According to Apple, the iPhone 4 has a new and better screen resolution:
3.5-inch (diagonal) widescreen Multi-Touch display
960-by-640-pixel resolution at 326 ppi
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.
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(8)
根据支持高分辨率屏幕在视图中,来自 Apple 文档:
According to Supporting High-Resolution Screens In Views, from the Apple docs:
这纯粹是猜测,但如果分辨率确实是 960 x 640 - 这恰好是当前版本分辨率的两倍。对于 iPhone 来说,检查应用程序构建目标并检测应用程序的旧版本并简单地将其缩放 2 是非常简单的。您永远不会注意到其中的差异。
This is purely speculation, but if the resolution really is 960 x 640 - that's exactly twice as high a resolution as the current version. It would be trivially simple for the iPhone to check the apps build target and detect a legacy version of the app and simply scale it by 2. You'd never notice the difference.
Engadget 对主题演讲的报道包括以下来自史蒂夫·乔布斯的文字记录
因此我推断,如果您使用现有的 API,您的应用程序将会得到扩展。如果您利用新的 iOS4 API,您就可以通过新像素获得所有乐趣。
Engadget's reporting of the keynote included the following transcript from Steve Jobs
So I infer from that, if you use existing APIs your app will get scaled up. If you take advantage of new iOS4 APIs, you can get all groovy with the new pixels.
听起来显示效果没问题,但我担心游戏中的逻辑。 TouchBegan 位置会返回新分辨率中的点吗?屏幕边界会有所不同,这些类型的事情可能对我来说可能是个问题。
It sounds like the display will be ok but I'm concerned about the logic in my game. Will touchesBegan positions return points in the new resolution? The screen bounds will be different, these types of things could potentially be problems for me.
出于显示目的缩放到双分辨率很简单,但是这种缩放是否适用于输入/输出屏幕坐标的所有 api?如果不是的话,事情就会破裂,不是吗?
如果它在整个框架中得到广泛处理,那就足够公平了。我想有很多潜在的 api 的这种效果。
Scaling to a double resolution for display purpose is straight forward, but will this scalling apply to all api's that input/output a screen coordinate? If not things are going to break aren't they?
Fair enough if it's been handled extensively throughout the framework.. I would imagine there are a lot of potential api's this effects.
对于来到此主题寻找移动 Web 界面解决方案的人,请查看 Webkit 博客上的这篇文章:http://webkit.org/blog/55/high-dpi-web-sites/
看来Webkit在四年前就已经解决了这个问题。
For people who are coming to this thread looking for a solution to a mobile web interface, check out this post on the Webkit blog: http://webkit.org/blog/55/high-dpi-web-sites/
It seems that Webkit has solved this problem four years ago.
是的,这是真的。
根据 WWDC 的说法,苹果似乎已经构建了某种形式的自动转换,以便应用程序的分辨率不会完全关闭。考虑将 DVD 向上转换为 HDTV。
我的猜测是,苹果知道大多数标准开发人员一直在使用什么,并且已经使用它们进行立即转换。当然,如果您正在编写一个应用程序来利用新的分辨率,它看起来会比苹果自动转换的结果好得多。
Yes it is true.
According to WWDC it appears that apple has build it some form of automatic conversion so that the resolution for applications will not be completely off. Think up-convert for dvd to HDTV's.
My guess would be that apple knows what most of the standards developers have been using and will already be using these for an immediate conversion. Of course if you are programming an application to take advantage of the new resolution it will look much nicer than whatever the result of apples auto-conversion is.
您的所有标签和系统按钮都将采用 326dpi,但您的图像仍将像素加倍,直到您添加高分辨率资源。我目前正在更新我的应用程序。如果您在 iPhone 4 sim 上构建并运行,则显示为 50%,请转到“窗口”>“规模> 100%看到真正的区别!标签很光滑,我的图像看起来令人震惊!
All of your labels and system buttons will be at 326dpi but your images will still be pixel doubled until you add the hi-res resources. I am currently updating my apps. If you build and run on the iPhone 4 sim then it is presented at 50%, go to Window > Scale > 100% to see the real difference! Labels are smooth, my images look shocking!