为什么 iOS 模拟器在适用于 Retina 的移动 Safari 中以较低的分辨率渲染我的图像?
我正在尝试在带有 Retina 显示屏的移动 Safari 中测试我的 Web 应用程序,并且只能访问 iOS 模拟器。我的图像全部以 2 倍分辨率渲染。我意识到这在某种程度上可能是有意义的,但我实际上希望图像以其自然分辨率渲染。
如何让 img
标签在 iPhone 视网膜设备上的 Mobile Safari 中以其自然分辨率呈现? (模拟器或其他)
更新
我不是在编写本机应用程序并调用 Safari,我正在编写一个普通的网站,并且我希望 Safari 呈现我的 img
针对视网膜和非视网膜设备以全分辨率标记图像。 (我知道,会接受并希望图像在视网膜设备上会更小)
I'm trying to test my web application in mobile Safari with a Retina display and only have access to iOS Simulator. My images are all rendering at 2x resolution. I realize that this probably makes sense on some level, but I actually want the images to render at their natural resolution.
How can I get img
tags to render at their natural resolution in Mobile Safari on an iPhone retina device? (simulator or otherwise)
UPDATE
I am not writing a native application and calling out to Safari, I'm writing a plain ol' website and I want Safari to render my img
tag images at full resolution both for retina and non-retina devices. (I'm aware, will accept and desire the fact that the image will be smaller on a retina device)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您需要使用媒体查询。如果没有它,Retina 不会自动假设您使用的是 2x 资源;这将导致所有网站图形以其预期大小的 50% 呈现。灾难!
(来自 HTML5 样板):
您还可以在此处使用ratio: 2 来仅针对 iPhone Retina,但某些设备(例如 Samsung Galaxy S)也具有相当高的分辨率 - 我认为是 220ppi - 尽管它们并不完全是两倍,所以请注意这一点。这些设备响应 1.5 查询。该比率来自实际像素占可见像素的数量。像素数学,耶!最终证明它们不是(也从来不是)绝对单位。
You need to make use of a media query. Retina won't automatically assume you are using 2x assets without it; that would cause all website graphics to render at 50% of their intended size. Disaster!
(from HTML5 boilerplate):
You can also use ratio: 2 here to target only iPhone Retina, but some devices, like Samsung Galaxy S, also have a pretty high res - 220ppi, i think - though they aren't exactly double, so watch out for that. These devices respond to the 1.5 query. The ratio comes from the amount of actual pixels that take up a visible pixel. Pixel math, yay! Finally proves they are not (and have never been) absolute units.
在模拟器中选择硬件
iOS 模拟器 -> 硬件 -> 设备 -> iPhone(Retina) 并运行您的应用程序
Select the hardware in simulator
iOS simulator->Hardware->Device->iPhone(Retina) and run your app
如果我理解正确的话,这里有一个类似的问题:
以及一个出色的关于此问题的博客文章:
iPhone 4 的全新 Retina 令人惊叹
显示
If I understood you correctly here is similar question:
And an excellent blog post on this matter:
stunning on the iPhone 4’s new Retina
display