在 4.2 上使用 UIWebView 时屏幕宽度始终为 480

发布于 2024-10-04 10:21:37 字数 362 浏览 1 评论 0原文

我正在尝试让 UIWebView 的内容适合屏幕。我尝试了两种方法。首先,我尝试使用加载的 html 中的视口元标记来设置视口宽度:

<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0" />

在我将模拟器和手机更新到 4.2 之前,这种方法就有效。

我还尝试将显示 html 的 UIWebView 设置为 YES。

这两个选项都不起作用。正如 document.documentElement.clientWidth 所示,宽度设置为 480

有什么想法吗?

I'm trying to get my UIWebView's content to fit the screen. I've tried two approaches. First, I tried to set the viewport width using the viewport meta tag in the loaded html:

<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0" />

This approach worked before I updated my simulator and phone to 4.2.

I also tried to set scalesPageToFit to YES for the UIWebView that displays the html.

Neither option work. The width is set to 480 as revealed by the document.documentElement.clientWidth

Any ideas?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

凡尘雨 2024-10-11 10:21:37

如果您在显示 Web 视图之前加载它,则会发现视口设置不正确。

Turns out that the viewport is set incorrectly if you load the webview before you display it.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文