Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Resize images in UIWebView to viewport size

I'm displaying HTML with some images inside a UIWebView in my iPhone App. When the images are wider than the viewport of the iPhone I get horizontal scrollers which I don't want because its mostly about the text not the images.

Is there a way to resize images displayed inside the UIWebView according to the width (best: even if the device is rotated)?

like image 671
lorem monkey Avatar asked Apr 20 '10 15:04

lorem monkey


2 Answers

If you want the maximum width to be the width of the webView, use the max-width CSS property.

max-width: 100%; width: auto; height: auto;

like image 192
Nikolai Krill Avatar answered Nov 16 '22 21:11

Nikolai Krill


If the image is inside a UIWebView you could try using css to size them to 100%?

Something like . . .

<img style="width:100%" src="..." />

DISCLAIMER: I don't have XCode handy to test that but it should work! You'll have to try it for yourself!

like image 27
deanWombourne Avatar answered Nov 16 '22 20:11

deanWombourne