开发者

Resize images in UIWebView to viewport size

开发者 https://www.devze.com 2022-12-27 07:23 出处:网络
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 d开发者_开发百科on\'t want beca

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 d开发者_开发百科on'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)?


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;


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!


for AutoHeightWebView you can put in customStyle props max-width:

<AutoHeightWebView
customStyle={`
        * {
            max-width: 100%;
        }
      `}
0

精彩评论

暂无评论...
验证码 换一张
取 消