I have a webview that displays an image, as shown in the code below. The bundle also has a DGT64@2x.png with dimensions of 128x128 for use on the iPhone4. The DGT64@2x.png never shows. Is there a way to display either/or depending on whether it's an iPhone or an iPhone4?
<img src="DGT64.png" width="64" height="64" align="left" style="padding:2px;"/>
I don't think the @2x
trick works with web content. Sounds really useful though, I would certainly file a bug with Apple to request that.
If you are generating the above HTML from your app then I think the best way for now will be to detect if you are running on a Retina display device and then adjusting the image name manually.
You can detect the Retina display by doing something like this:
if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)]) {
if ([[UIScreen mainScreen] scale] == 2) {
// Use high resolution images
}
}
(Took that code from an answer I found here in SO)