iOS WKWebview loadHTMLString文字图片正常显示

// 话题网页内容
        CGFloat contentW = XJ_ScreenWidth - 20 ;
        CGFloat contentX = 10;
        
        NSString *jScript = @"var meta = document.createElement('meta'); meta.setAttribute('name', 'viewport'); meta.setAttribute('content', 'width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no'); 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.contentWbv = [[WKWebView alloc] initWithFrame:CGRectMake(contentX, HEIGHT(titleLb) + Y(titleLb) + padding, contentW, 100) configuration:wkWebConfig];
        self.contentWbv.backgroundColor = [UIColor whiteColor];
        self.contentWbv.navigationDelegate = self;
       
        self.contentWbv.scrollView.bounces = NO;
        self.contentWbv.scrollView.scrollEnabled = NO;
                       
        NSString *htmls = [NSString stringWithFormat:@" \n"
                           " \n"
                           " \n"
                           " \n"
                           ""
                           "%@"
                           ""
                           "",self.actDetailModel.brief];
       
        [self.contentWbv loadHTMLString:htmls baseURL:nil];

你可能感兴趣的:(iOS WKWebview loadHTMLString文字图片正常显示)