【发布时间】:2018-12-19 12:29:50
【问题描述】:
您好,我正在尝试将带有以下元素的 html 加载到 WKWebView:
<iframe align=\"middle\"
allowtransparency=\"\"
frameborder=\"0\"
height=\"820px\"
id=\"\"
scrolling=\"no\"
seamless=\"\"
src=\"//my.site.ru/files_static/edd/2016/speech_countries/6/first.html\"
width=\"100%\">
</iframe>
WKWebView 无法加载内容,而是显示一个空白屏幕。但是如果我在 src 中添加 https 或 http,则元素加载成功:
<iframe align=\"middle\"
allowtransparency=\"\"
frameborder=\"0\"
height=\"820px\"
id=\"\"
scrolling=\"no\"
seamless=\"\"
src=\"http://my.site.ru/files_static/edd/2016/speech_countries/6/first.html\"
width=\"100%\">
</iframe>
我在 WKWebView、WKPreferences、WKWebViewConfiguration 中搜索了一些属性来为 WKWebView 设置默认协议,但没有找到任何东西。 WKWebview可以在没有协议的情况下通过链接加载html吗?
找到答案:调用loadHtmlString时需要设置baseUrl字符串
【问题讨论】:
-
请制作正确的html格式请检查reddit.com/r/swift/comments/8cy0lh/…