【问题标题】:resize html file content using Swift 4使用 Swift 4 调整 html 文件内容的大小
【发布时间】:2026-01-30 00:55:01
【问题描述】:

我将 Web 文件(html、css、javascript)添加到我的 iOS 应用程序中,并使用 WKWebView 正确连接了所有内容。不幸的是,对于 iphone 屏幕来说,html 太宽并且不能正确滚动。在尝试了该站点、苹果文档等的几种潜在解决方案后,没有任何效果。 html 内容对于 iPhone 屏幕尺寸来说太大了。如果我返回并手动更改 CSS 中的所有像素尺寸以适应一种 iPhone 屏幕尺寸,那么它对于其他手机尺寸看起来就不合适了。有没有办法使用 Swift 4 和 WKWebview 缩放以适应或启用水平滚动?

【问题讨论】:

    标签: html ios css swift wkwebview


    【解决方案1】:

    尝试以下任一方法:

    <meta name="viewport" content="user-scalable=1.0,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0">
    <meta name="format-detection" content="telephone=no">
    <meta name="apple-mobile-web-app-capable" content="yes" />
    

    【讨论】: