WKWebVIew内容文字自适应

    xiaoxiao2021-03-25  123

    - (void)viewDidLoad { [super viewDidLoad]; self.title = @"FAQ"; NSString *jScript = @"var meta = document.createElement('meta'); meta.setAttribute('name', 'viewport'); meta.setAttribute('content', 'width=device-width'); document.getElementsByTagName('head')[0].appendChild(meta);"; 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; self.webView = [[WKWebView alloc] initWithFrame:self.view.bounds configuration:wkWebConfig]; self.webView.allowsBackForwardNavigationGestures = YES; self.webView.navigationDelegate = self; [self.view addSubview:self.webView]; [MBProgressHUD showMessage:@"请稍后"]; NSString *sting = [NSString stringWithFormat:@"%@%@",PRE_URL,self.urlString]; NSString *str = [sting stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; NSURL *url = [NSURL URLWithString:str]; [self.webView loadRequest:[NSURLRequest requestWithURL:url]]; // Do any additional setup after loading the view. }
    转载请注明原文地址: https://ju.6miu.com/read-9999.html

    最新回复(0)