Commit 4792ce44f258f8df9283fe3d6511601c00c71202

Authored by iOS-Xiaowen
1 parent 9530e750

no message

CNLiveScioLive/Pages/Live/Controller/GraphicLiveViewController.m
@@ -127,8 +127,32 @@ @@ -127,8 +127,32 @@
127 relatedWebView.tag = 1000; 127 relatedWebView.tag = 1000;
128 [backgroundView addSubview:relatedWebView]; 128 [backgroundView addSubview:relatedWebView];
129 129
130 - NSString* htmlHeader = [[NSString alloc] initWithFormat:@"<html><font style=\"font-size:20px;\"><strong>%@</strong></font><br><p>%@</p><p>来源 : 国新网</p><body>",[_dictionary objectForKey:@"title"],[_dictionary objectForKey:@"liveStartDateTime"]]; 130 +// NSString* htmlHeader = [[NSString alloc] initWithFormat:@"<html><font style=\"font-size:20px;\"><strong>%@</strong></font><br><p>%@</p><p>来源 : 国新网</p><body>",[_dictionary objectForKey:@"title"],[_dictionary objectForKey:@"liveStartDateTime"]];
  131 +// NSString* htmlFooter = [[NSString alloc] initWithFormat:@"<div class=\"logo\" style=\"text-indent:2em\">%@</div></body></html>",[_dictionary objectForKey:@"Description"]];
  132 +// NSString* strHtml = [[NSString alloc] initWithFormat:@"%@%@",htmlHeader,htmlFooter];
  133 +// [relatedWebView loadHTMLString:strHtml baseURL:nil];
  134 +
  135 + NSString *jScript = @"var meta = document.createElement('meta'); meta.setAttribute('name', 'viewport'); meta.setAttribute('content', 'width=device-width'); document.getElementsByTagName('head')[0].appendChild(meta);";
  136 +
  137 + WKUserScript *wkUScript = [[WKUserScript alloc] initWithSource:jScript injectionTime:WKUserScriptInjectionTimeAtDocumentEnd forMainFrameOnly:YES];
  138 + WKUserContentController *wkUController = [[WKUserContentController alloc] init];
  139 + [wkUController addUserScript:wkUScript];
  140 +
  141 + WKWebViewConfiguration *config = [[WKWebViewConfiguration alloc] init];
  142 + config.userContentController = wkUController;
  143 + relatedWebView = [[WKWebView alloc] initWithFrame:CGRectZero configuration:config];
  144 + relatedWebView.scrollView.backgroundColor = [UIColor whiteColor];
  145 + relatedWebView.backgroundColor = [UIColor whiteColor];
  146 + relatedWebView.scrollView.bounces = NO;
  147 + relatedWebView.scrollView.scrollEnabled = NO;
  148 + relatedWebView.navigationDelegate = self;
  149 + relatedWebView.opaque = NO;
  150 + relatedWebView.tag = 1000;
  151 + [backgroundView addSubview:relatedWebView];
  152 +
  153 + NSString* htmlHeader = [[NSString alloc] initWithFormat:@"<html><font style=\"font-size:20px;\"><strong>%@</strong></font><br><p>%@</p><p>来源:%@</p><body>",[_dictionary objectForKey:@"title"],[_dictionary objectForKey:@"liveStartDateTime"], @"国新网"];
131 NSString* htmlFooter = [[NSString alloc] initWithFormat:@"<div class=\"logo\" style=\"text-indent:2em\">%@</div></body></html>",[_dictionary objectForKey:@"Description"]]; 154 NSString* htmlFooter = [[NSString alloc] initWithFormat:@"<div class=\"logo\" style=\"text-indent:2em\">%@</div></body></html>",[_dictionary objectForKey:@"Description"]];
  155 +
132 NSString* strHtml = [[NSString alloc] initWithFormat:@"%@%@",htmlHeader,htmlFooter]; 156 NSString* strHtml = [[NSString alloc] initWithFormat:@"%@%@",htmlHeader,htmlFooter];
133 [relatedWebView loadHTMLString:strHtml baseURL:nil]; 157 [relatedWebView loadHTMLString:strHtml baseURL:nil];
134 158