Customize User Agent in UIWebView for iOS7

UIWebView 會去 NSUserDefaults 裡找...很神奇...:)

- (void)setDefaultWebViewUserAgent
{
  // Get Default UserAgent.
  UIWebView *webView = [[UIWebView alloc] initWithFrame:CGRectZero];
  NSString *agent = [webView stringByEvaluatingJavaScriptFromString:@"navigator.userAgent"];
  // Mozilla/5.0 (iPhone; CPU iPhone OS 7_1_2 like Mac OS X) AppleWebKit/537.51.2 (KHTML, like Gecko) Mobile/11D257

  // Save it.
  NSDictionary *dictionary = [NSDictionary dictionaryWithObjectsAndKeys:[NSString stringWithFormat:@"%@;V Pass WebView", agent], @"UserAgent", nil];
  [[NSUserDefaults standardUserDefaults] registerDefaults:dictionary];
}