iOS

iOS客户端添加UserAgent

2017-04-07  本文已影响15人  夏天爱大树

最近公司的项目需要用到WebView,WebView需要修改网页的布局(比如去掉某些不需要的header),需要添加UserAgent。上代码:

//一般写在appdelegate方法里
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
 
    //regist the new agent
    NSDictionary *dictionnary = [[NSDictionary alloc] initWithObjectsAndKeys:UA, @"UserAgent", nil];    
    [[NSUserDefaults standardUserDefaults] registerDefaults:dictionnary];
    return YES;
}

具体原理我也不是很清楚,如果有知道的请告诉我,谢谢!

上一篇 下一篇

猜你喜欢

热点阅读