vendredi 14 mars 2014

Setting the UserAgent globally for an entire UIWebView and then changing it


Vote count:

0




Changing the UserAgent can be done very nicely with:



[[NSUserDefaults standardUserDefaults] registerDefaults:@{ @"UserAgent": @"My String" }];


And if I make a new UIWebView after calling the above code the UserAgent does change. But, let's say I wanted to allow the user to change the UserAgent, refresh the page, and have the new UserAgent take affect. The above line doesn't seem to do this. I have to create a new UIWebView and set it's URL to the previous UIWebView's URL and start that request. Is there a better way to do this?


The only other option seems to be to use a NSMutableURLRequest and set the UserAgent their, but then when the user clicks on the link inside the UIWebView, would the UserAgent still be right? Or would it default back to the global one?



asked 22 secs ago






Aucun commentaire:

Enregistrer un commentaire