Skip to content

Instantly share code, notes, and snippets.

@bluebanboom
Created October 11, 2012 16:08
Show Gist options
  • Save bluebanboom/3873469 to your computer and use it in GitHub Desktop.
Save bluebanboom/3873469 to your computer and use it in GitHub Desktop.
Change UIWebView User-Agent.
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)req navigationType:(UIWebViewNavigationType)navigationType
{
NSMutableURLRequest *request = (NSMutableURLRequest *)req;
if ([request respondsToSelector:@selector(setValue:forHTTPHeaderField:)]) {
[request setValue:@"Mozilla/5.0 (iPhone; U; CPU iPhone OS 3_0 like Mac OS X; en-us) AppleWebKit/528.18 (KHTML, like Gecko) Version/4.0 Mobile/7A341 Safari/528.16" forHTTPHeaderField:@"User_Agent"];
}
return YES;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment