iOS WKWebView 内容超出屏幕后不显示超出部分的内容

NSString *head = @" ";
content = [NSString stringWithFormat:@"%@%@",head,content];// 超出屏幕的部分不显示

/// 适配内容字体不会变小,禁止内容放大缩小,禁止内容左右弹性属性
NSString *jScript = @"var script = document.createElement('meta');"
"script.name = 'viewport';"
"script.content=\"width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no\";"
"document.getElementsByTagName('head')[0].appendChild(script);";
WKUserScript *wkUScript = [[WKUserScript alloc] initWithSource:jScript injectionTime:WKUserScriptInjectionTimeAtDocumentEnd forMainFrameOnly:YES];
WKUserContentController *wkUController = [[WKUserContentController alloc] init];
[wkUController addUserScript:wkUScript];
    
WKWebViewConfiguration *wkWebConfig = [[WKWebViewConfiguration alloc] init];
wkWebConfig.userContentController = wkUController;
    
contentWebView = [[WKWebView alloc] initWithFrame:CGRectZero configuration:wkWebConfig];
contentWebView.navigationDelegate = self;
contentWebView.UIDelegate = self;
///修复在cell上滑动html内容出现卡顿
contentWebView.scrollView.bounces = NO;
///为YES时,超出屏幕宽度可滑动
contentWebView.scrollView.scrollEnabled = NO;
[cell.contentView addSubview:contentWebView];
[contentWebView mas_makeConstraints:^(MASConstraintMaker *make) {
    make.top.bottom.offset(0);
    make.left.offset(10);
    make.right.offset(-10);
}];
[contentWebView loadHTMLString:content baseURL:nil];

你可能感兴趣的:(iOS WKWebView 内容超出屏幕后不显示超出部分的内容)