美文网首页
WKwebview H5首页导航栏高度不对

WKwebview H5首页导航栏高度不对

作者: d_dong_q | 来源:发表于2018-11-14 11:11 被阅读0次

有一个全是H5页面的项目,h5定义的导航栏高度比前端设置的要小,经查询WKwebview在加载第一个页面时不会去加载UserAgent,解决方法:

在AppDelegate.m 的- (BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions 里加入

//H5首页导航栏高度不对

    UIWebView *webView = [[UIWebView alloc] initWithFrame:CGRectZero];

    NSString *userAgent = [webView stringByEvaluatingJavaScriptFromString:@"navigator.userAgent"];

    NSString*newUserAgent = [userAgent stringByAppendingString:@"****"];//自定义需要拼接的字符串

    NSDictionary *dictionary = [NSDictionary dictionaryWithObjectsAndKeys:newUserAgent, @"UserAgent", nil];

    [[NSUserDefaults standardUserDefaults] registerDefaults:dictionary];

    [[NSUserDefaults standardUserDefaults] synchronize];

相关文章

网友评论

      本文标题:WKwebview H5首页导航栏高度不对

      本文链接:https://www.haomeiwen.com/subject/cmmdfqtx.html