iOS WKWebView ios9以上版本配置 与 设置UserAgent(用户代理), 解决点击web, 客户端接收不到web事件问题


项目运行在ios9上需要在info.plist文件中配置加入如下信息,

App Transport Security Settings
      Allow Arbitrary Loads = YES

<key>NSAppTransportSecurity</key>
<dict>
    <key>NSAllowsArbitraryLoads</key>
    <true/>
</dict>

 设置 UserAgent(用户代理)

用户代理: 把硬件的一些信息告诉浏览器

// 注册代理, 在某些情况点击菜单没有交互, 不妨设置看看

[self.yourSite setValue:@"Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.3; Trident/7.0; .NET4.0E; .NET4.0C)" forKey:@"applicationNameForUserAgent"];

如果在ios9上也可以这么设置,不过只能用再ios 9及以上的系统当中

        if ([[[UIDevice currentDevice] systemVersion]  isEqual: @"9.0"])
        {
            self.yourSite.customUserAgent = @"Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.3; Trident/7.0; .NET4.0E; .NET4.0C)";
        }

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM