WKWebViewConfiguration *config = [[WKWebViewConfiguration alloc] init];
config.preferences = [WKPreferences new];
config.preferences.minimumFontSize = 10;
config.preferences.javaScriptEnabled = YES;
config.preferences.javaScriptCanOpenWindowsAutomatically = YES;
//下方代码,禁止缩放
WKUserContentController *userController = [WKUserContentController new];
NSString *js = @" $('meta[name=description]').remove(); $('head').append( '' );";
WKUserScript *script = [[WKUserScript alloc] initWithSource:js injectionTime:WKUserScriptInjectionTimeAtDocumentEnd forMainFrameOnly:NO];
NSMutableString *javascript = [NSMutableString string]; [javascript appendString:@"document.documentElement.style.webkitTouchCallout='none';"];//禁止长按
[javascript appendString:@"document.documentElement.style.webkitUserSelect='none';"];//禁止选择
WKUserScript *noneSelectScript = [[WKUserScript alloc] initWithSource:javascript injectionTime:WKUserScriptInjectionTimeAtDocumentEnd forMainFrameOnly:YES];
[userController addUserScript:script];
[userController addUserScript:noneSelectScript];
[userController addScriptMessageHandler:self name:@"openInfo"];
config.userContentController = userController;
_webView = [[WKWebView alloc] initWithFrame:CGRectZero configuration:config];
_webView.scrollView.bounces = false;//禁止滑动