ios开发 设置webview的userAgent

UIWebView *webView=[[UIWebView alloc] init];

//修改useragent

   NSString *useragent = [webView stringByEvaluatingJavaScriptFromString:@"navigator.userAgent"];

   NSString *uaa = [useragent stringByAppendingString:@"iosclient"];//自定义需要拼接的字符串

   NSDictionary *dictionary = [NSDictionary dictionaryWithObjectsAndKeys:uaa, @"UserAgent",@"ww", nil];

   [[NSUserDefaults standardUserDefaults] registerDefaults:dictionary];

self.title = [webView stringByEvaluatingJavaScriptFromString:@"document.title"];

ios开发 设置webview的userAgent_第1张图片
图片发自App

你可能感兴趣的:(ios开发 设置webview的userAgent)