great!
it works perfectly!
I was struggling to find a good way to do this for android as well. This is what I've found
Really simple way is to fetch the...
I think this board is the proper place to ask you about the activation proccess. My link is not working properly, do you know why it is...
You can put what you want in the desired user agent.
Yes it's "UserAgent", there is no typo, but don't forget that you need to set...
Can you give us a sample of what belongs in "Desired User Agent?" I'm using:
Mozilla/5.0 (iPhone Simulator; U; CPU iPhone OS 4_2...
Casey (not verified) - Dynamic UserAgent
Thanks for this awesome post. This is seemingly the only method that currently works without using undocumented methods.
I have this code working, however when I call the function again, to change the UserAgent to something else, UIWebView's do not update. In order to successfully update the UserAgent I need to remove/release the UIWebView and alloc/show it again.
-(void)setUserAgent:(NSString*)userAgent {NSDictionary *userAgentReplacement = [[NSDictionary alloc] initWithObjectsAndKeys:userAgent, @"UserAgent", nil];
[[NSUserDefaults standardUserDefaults] registerDefaults:userAgentReplacement];
//SHOULDN'T HAVE TO DO THIS
//get webView values then release
CGRect webFrame = webView.frame;
NSURLRequest *webRequest = [[webView request] retain];
[webView removeFromSuperview];
[webView release];
//allow webview and add to screen again
webView = [[UIWebView alloc] initWithFrame:webFrame];
[webView setScalesPageToFit:TRUE];
[webView setDelegate:self];
[self.view addSubview:webView];
}
This is mostly OK however it causes the UIWebView to lose all history. Is there any way to update the UserAgent without having to create a new UIWebView in order to have it take effect?
Thanks again