6

I have this UIWebView on my app that shows a local html file. Do the images on that web view follow the @2x rule? I mean, if I build both, the regular and the @2x images will the webview load the retina ones for the iPhone 4?

remember that the images are being loaded by the HTML tag , not by any UIImage method.

thanks.

Duck
  • 34,902
  • 47
  • 248
  • 470

5 Answers5

7

Nope. It's not too hard to roll your own though, as WebKit supports this CSS rule:

@media only screen and (-webkit-min-device-pixel-ratio: 2) {
    /* this is a retina display device */
}

You can also use the -webkit-background-size and the usual width and height selectors to ensure the images display at the correct physical size.

Jonathan Grynspan
  • 43,286
  • 8
  • 74
  • 104
4

Jonathon Grynspan is correct. I recommend reading Aral Balkan's tutorial on the topic. This was what I read when I implemented @2x graphics for a recent mobile site:

How to make your web content look stunning on the iPhone 4’s new Retina display

typeoneerror
  • 55,990
  • 32
  • 132
  • 223
1

No, I just tried an experiment and the UIWebView did not pick up the @2x image.

Bogatyr
  • 19,255
  • 7
  • 59
  • 72
  • You might want to post the experiment. – typeoneerror Feb 09 '11 at 20:25
  • 1
    The experiment was precisely what the OP asked about: Created a sample project, put in a UIWebView, put in an image tag to a test image, created a @2x version of the image, ran the project on a retina device, and the non-@2x version of the image showed up. Why downvote, my answer is complete and correct! Not as good as the other ones since I didn't say how to work around it, so vote those up instead, but downvoting a correct answer? Really... – Bogatyr Feb 10 '11 at 06:24
0

The best solution i.m.o is to always load a retina image, and set the size to 50% for the image. It will look good on retina and non-retina displays. Should be sufficient.

ullstrm
  • 9,812
  • 7
  • 52
  • 83
0

Maybe my answer to a similar question is interesting UIWebView and iPhone 4 retina display. It uses Javascript to load scaled images and set the width properly.

Community
  • 1
  • 1
Mattias Wadman
  • 11,172
  • 2
  • 42
  • 57