gpt4 book ai didi

ios - WKWebView 不尊重宽度=设备宽度

转载 作者:行者123 更新时间:2023-12-01 15:43:17 24 4
gpt4 key购买 nike

我正在将一个简单的 html 字符串加载到 WKWebView 中,我的目标是在该 webview 中显示全屏图像。

问题在于图像的缩放比例似乎是预期的两倍。

我只是使用

加载 WKWebView
NSString *html = @"..."  // the content
[self.webView loadHTMLString:html baseURL:[[NSBundle mainBundle] bundleURL]];

我希望图像是全屏并适合屏幕

enter image description here

但我得到的图像似乎是屏幕分辨率的两倍(不是左下角的文字(

enter image description here

我尝试使用 initial-scalemaximum-scale

<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>

但它不起作用。

这似乎只发生在 HTML 中 base64 编码的图像上,但这是我需要的。

HTML 是

<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8"/>
<meta name="viewport" content="width=device-width"/>
</head>

<img src="data:image/png;base64, ...">
<!-- <img src="http://placehold.it/750x1334"> -->
</body>
</html>

Here is the html complete HTML

最佳答案

我添加了,它正在工作。

HTML 是:

      <html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
<style>
img {
width:auto;
height:auto;
max-width:100%;
max-height:90vh;
}
</style>
</head>
<body>
<!-- body container -->
</body>
</html>

关于ios - WKWebView 不尊重宽度=设备宽度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39592671/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com