<legend id='q7qba'><style id='q7qba'><dir id='q7qba'><q id='q7qba'></q></dir></style></legend>
        • <bdo id='q7qba'></bdo><ul id='q7qba'></ul>
      1. <tfoot id='q7qba'></tfoot>
      2. <small id='q7qba'></small><noframes id='q7qba'>

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

        加载桌面版 WKWebView iOS 9

        时间:2023-07-08
        <legend id='WKSSJ'><style id='WKSSJ'><dir id='WKSSJ'><q id='WKSSJ'></q></dir></style></legend>

      3. <tfoot id='WKSSJ'></tfoot>

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

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

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

                    <tbody id='WKSSJ'></tbody>
                1. 本文介绍了加载桌面版 WKWebView iOS 9的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  直到最近

                  let url = NSURL (string:http://asite.com)        
                  let request = NSMutableURLRequest(URL: url!)         
                  
                  //iOS loads the mobile version of asite.com which does not have the required DOM so we force the desktop version by setting new value forHTTPHeadrField
                  let newUserAgent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.6 Safari/537.11"
                  
                  request.setValue(newUserAgent, forHTTPHeaderField: "User_Agent")
                  
                  let config = WKWebViewConfiguration()        
                  
                  //even though we dont need to see it the webpage needs to appear but we set its frame to CGRectZero so its hidden from user 
                  
                  let ghostWebView : WKWebView = WKWebView(frame:CGRectZero, configuration: config)        
                  ghostWebView.loadRequest(request)
                  

                  这将强制使用该网站的桌面版本.但是它刚刚停止工作.不知道确切的时间,但最近.

                  This would force the desktop version of the site. However it has just stopped working. Not sure exactly when but very recently.

                  有什么想法吗?

                  google 搜索结果也显示了一些用途

                  Also google results show some use

                  用户代理"

                  对于 HTTPHeaderField 等

                  for the HTTPHeaderField and others

                  用户代理"

                  两者有什么区别?

                  更新:我通过将用户代理字符串更改为

                  Update: I solved the issue by changing the User Agent string to

                  "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36(KHTML,如 Gecko)Chrome/41.0.2227.1 Safari/537.36"

                  "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2227.1 Safari/537.36"

                  我是从

                  http://www.useragentstring.com

                  所以我的新问题是这些用户代理字符串多久更改一次,有没有办法让我的应用自动更新到最新的?

                  So my new question is how often do these user agent strings change and is there a way for my app to auto update to the newest one?

                  推荐答案

                  帮助任何在这里找到答案的人.解决方案是

                  To help any who find themselves here for an answer. The solution was

                  UserDefaults.standard.register(defaults: ["UserAgent" : "Chrome Safari"])
                  

                  这篇关于加载桌面版 WKWebView iOS 9的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:Web 服务 Http 身份验证 - Android 上的 KSOAP2 下一篇:在 Objective-C 中暂停/恢复下载

                  相关文章

                  <tfoot id='WovZD'></tfoot>

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

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

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