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

      1. <small id='ygwnk'></small><noframes id='ygwnk'>

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

        <legend id='ygwnk'><style id='ygwnk'><dir id='ygwnk'><q id='ygwnk'></q></dir></style></legend>
        <tfoot id='ygwnk'></tfoot>
      2. 如何获取 UIWebView 用户代理

        How to get UIWebView User-Agent(如何获取 UIWebView 用户代理)

          <tfoot id='cn2d1'></tfoot>
            <tbody id='cn2d1'></tbody>
            <bdo id='cn2d1'></bdo><ul id='cn2d1'></ul>
          • <legend id='cn2d1'><style id='cn2d1'><dir id='cn2d1'><q id='cn2d1'></q></dir></style></legend>

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

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

                  本文介绍了如何获取 UIWebView 用户代理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我在使用一台远程服务器时遇到了问题.我的应用程序使用 [NSData initWithContentsOfURL:] 方法向服务器发出请求,作为响应,我得到了在 UIWebView 中打开的网站 url.

                  I've got a problem working with one remote server. My app makes a request to a server using [NSData initWithContentsOfURL:] method and as a response I get website's url which I open in UIWebView.

                  问题是这些请求具有不同的用户代理,服务器无法正确地为我服务,因为它希望我使用相同的用户代理发送所有请求.我知道如何更改用户代理(例如 更改 UIWebView 中的用户代理(iPhone SDK)) 但我真正想要的是以某种方式获取 UIWebView 的 User-Agent 并将其设置为 [NSData initWithContentsOfURL:] 以避免服务器端出现问题

                  The problem is that those requests have different User-Agent and server can't serve me correct because it expects that I send all requests with the same User-Agent. I know how to change User-Agent (e.g Change User Agent in UIWebView (iPhone SDK)) but what I really want it is somehow to get UIWebView's User-Agent and set it to [NSData initWithContentsOfURL:] to avoid problems with server side

                  推荐答案

                  我刚刚遇到了类似的问题,需要使 NSURLConnection 发送的用户代理与 UIWebView 发送的用户代理匹配.我的解决方案是创建一个 UIWebView,然后使用 javascript 拉出用户代理.

                  I just ran into a similar issue and needed to make the user agent sent by an NSURLConnection match the one sent by a UIWebView. My solution was to create a UIWebView and then just use javascript to pull out the user agent.

                  UIWebView* webView = [[UIWebView alloc] initWithFrame:CGRectZero];
                  NSString* secretAgent = [webView stringByEvaluatingJavaScriptFromString:@"navigator.userAgent"];

                  这篇关于如何获取 UIWebView 用户代理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  In Objective-c, safe and good way to compare 2 BOOL values?(在 Objective-c 中,比较 2 个 BOOL 值的安全和好方法?)
                  iOS: Use a boolean in NSUserDefaults(iOS:在 NSUserDefaults 中使用布尔值)
                  Typical UDP latency on iPhone over 3G - are my numbers right?(iPhone 在 3G 上的典型 UDP 延迟 - 我的数字对吗?)
                  Scan networks (SSID#39;s) on iOS 7 by using private API(使用私有 API 在 iOS 7 上扫描网络 (SSID))
                  Determine whether iPhone is really connected to the internet or just behind a restricted hotspot(确定 iPhone 是真正连接到互联网还是仅在受限热点后面)
                  Am I using CNCopyCurrentNetworkInfo correctly?(我正确使用 CNCopyCurrentNetworkInfo 吗?)

                    <legend id='V6Bep'><style id='V6Bep'><dir id='V6Bep'><q id='V6Bep'></q></dir></style></legend>

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

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