我加载HTML
到我的UIWebView
那个包括Text
和Images
.
Text
适合UIWebView
和Images
不适合UIWebView
.
它太大了UIWebView
.
它显示在结尾处的滚动条UIWebView
.
我想在UWebView中调整图像适合大小.所以我测试了以下代码.
self.myWebView.scalesPageToFit = YES;
但它已修复,包括文本和文本太小,无法读取和图像是固定的.
我想正常设置文本,只想要适合大小的图像UIWeView
.
我该怎么做?
我用css解决了这个问题.下面样式标记中包含的css将确保自动调整图像大小,保持UIWebView宽度的纵横比.希望这可以帮助!
NSString *strTemplateHTML = [NSString stringWithFormat:@"<html><head><style>img{max-width:100%%;height:auto !important;width:auto !important;};</style></head><body >%@</body></html>", @"insert your html content here"]; [webView loadHTMLString:strTemplateHTML baseURL:nil];
使用视频元标记由iPhone/iPad上的UIWebView使用,以确定如何显示网页.
<meta name="viewport" content=" />
请参阅以下链接了解更多详情:
https://developer.apple.com/library/ios/DOCUMENTATION/AppleApplications/Reference/SafariWebContent/UsingtheViewport/UsingtheViewport.html