iOS----------WKWebView修改userAgent

WKWebViewConfiguration* webViewConfig = [[WKWebViewConfiguration alloc]init];
NSLog(@"修改前 = %@",webViewConfig.applicationNameForUserAgent);
//正确设置UserAgent的代码
webViewConfig.applicationNameForUserAgent = [NSString stringWithFormat:@"%@ %@",webViewConfig.applicationNameForUserAgent,@"xxxios"];;
NSLog(@"修改后 = %@",webViewConfig.applicationNameForUserAgent);
_wkWebView = [[WKWebView alloc]initWithFrame:CGRectMake(0, 0, kScreenWidth, kScreenHeight) configuration:webViewConfig];

posted @ 2020-12-22 16:18  iOS张文权  阅读(529)  评论(0编辑  收藏  举报