• <small id='NOpG6'></small><noframes id='NOpG6'>

    <i id='NOpG6'><tr id='NOpG6'><dt id='NOpG6'><q id='NOpG6'><span id='NOpG6'><b id='NOpG6'><form id='NOpG6'><ins id='NOpG6'></ins><ul id='NOpG6'></ul><sub id='NOpG6'></sub></form><legend id='NOpG6'></legend><bdo id='NOpG6'><pre id='NOpG6'><center id='NOpG6'></center></pre></bdo></b><th id='NOpG6'></th></span></q></dt></tr></i><div id='NOpG6'><tfoot id='NOpG6'></tfoot><dl id='NOpG6'><fieldset id='NOpG6'></fieldset></dl></div>

      <bdo id='NOpG6'></bdo><ul id='NOpG6'></ul>

    1. <legend id='NOpG6'><style id='NOpG6'><dir id='NOpG6'><q id='NOpG6'></q></dir></style></legend>
        <tfoot id='NOpG6'></tfoot>
      1. WKWebView 中的字体看起来比 UIWebView 中的小

        时间:2023-10-22

              <tfoot id='GfDnD'></tfoot>

              <small id='GfDnD'></small><noframes id='GfDnD'>

                <bdo id='GfDnD'></bdo><ul id='GfDnD'></ul>

                <legend id='GfDnD'><style id='GfDnD'><dir id='GfDnD'><q id='GfDnD'></q></dir></style></legend>
                <i id='GfDnD'><tr id='GfDnD'><dt id='GfDnD'><q id='GfDnD'><span id='GfDnD'><b id='GfDnD'><form id='GfDnD'><ins id='GfDnD'></ins><ul id='GfDnD'></ul><sub id='GfDnD'></sub></form><legend id='GfDnD'></legend><bdo id='GfDnD'><pre id='GfDnD'><center id='GfDnD'></center></pre></bdo></b><th id='GfDnD'></th></span></q></dt></tr></i><div id='GfDnD'><tfoot id='GfDnD'></tfoot><dl id='GfDnD'><fieldset id='GfDnD'></fieldset></dl></div>
                  <tbody id='GfDnD'></tbody>

                  本文介绍了WKWebView 中的字体看起来比 UIWebView 中的小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我将 UIWebView 更改为 WKWebView,但是,使用相同的 html,WKWebView 中的字体看起来比 UIWebView 中的字体小.我不希望这种情况发生,那么有什么办法可以避免这种变化吗?

                  I changed UIWebView to WKWebView, however, with the same html, the font in WKWebView looks like smaller than in UIWebView. I don't want this happen, so is there any way to avoid this change?

                  推荐答案

                  最后我通过添加一个html字符串解决了这个问题:

                  Finally I solved this problem by adding an html string:

                  • 对于 Objective-C:
                  NSString *headerString = @"<head><meta name='viewport' content='width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no'></head>";
                  [self.webView loadHTMLString:[headerString stringByAppendingString:yourHTMLString] baseURL:nil];
                  

                  • 对于 Swift:
                  • let headerString = "<head><meta name='viewport' content='width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no'></head>"
                    webView.loadHTMLString(headerString + yourHTMLString, baseURL: nil)
                    


                    另外,如果你想加载 url 而不是 html 你可以试试:


                    What's more,if you want to load url rather than html you can try:

                    private var isInjected: Bool = false
                    webView.navigationDelegate = self
                    // MARK: - WKNavigationDelegate
                    func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
                        if isInjected == true {
                            return
                        }
                        self.isInjected = true
                        // get HTML text
                        let js = "document.body.outerHTML"
                        webView.evaluateJavaScript(js) { (html, error) in
                            let headerString = "<head><meta name='viewport' content='width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no'></head>"
                            webView.loadHTMLString(headerString + (html as! String), baseURL: nil)
                        }
                        
                    }
                    

                    这篇关于WKWebView 中的字体看起来比 UIWebView 中的小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                    1. <tfoot id='RIK9j'></tfoot>
                        <i id='RIK9j'><tr id='RIK9j'><dt id='RIK9j'><q id='RIK9j'><span id='RIK9j'><b id='RIK9j'><form id='RIK9j'><ins id='RIK9j'></ins><ul id='RIK9j'></ul><sub id='RIK9j'></sub></form><legend id='RIK9j'></legend><bdo id='RIK9j'><pre id='RIK9j'><center id='RIK9j'></center></pre></bdo></b><th id='RIK9j'></th></span></q></dt></tr></i><div id='RIK9j'><tfoot id='RIK9j'></tfoot><dl id='RIK9j'><fieldset id='RIK9j'></fieldset></dl></div>
                          <tbody id='RIK9j'></tbody>

                        <small id='RIK9j'></small><noframes id='RIK9j'>

                        • <bdo id='RIK9j'></bdo><ul id='RIK9j'></ul>
                          <legend id='RIK9j'><style id='RIK9j'><dir id='RIK9j'><q id='RIK9j'></q></dir></style></legend>