Commit 79777e1e57d618401aad75cb240b73980a3534ff

Authored by iOS-Xiaowen
1 parent 5fdc06be

no message

CNLiveScioLive/Pages/Live/Controller/GraphicLiveViewController.m
@@ -316,15 +316,17 @@ @@ -316,15 +316,17 @@
316 // 页面加载完成之后调用 316 // 页面加载完成之后调用
317 - (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation 317 - (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation
318 { 318 {
319 - CGRect frame = relatedWebView.frame;  
320 - frame.size.width = MainScreenWidth;  
321 - frame.size.height = 1;  
322 - relatedWebView.frame = frame;  
323 - [webView evaluateJavaScript:@"document.body.scrollHeight"completionHandler:^(id _Nullable result,NSError * _Nullable error){  
324 - NSLog(@"scrollHeight高度:%.2f",[result floatValue]);  
325 - descriptionHeight = [result floatValue];  
326 - [relatedWebView setFrame:CGRectMake(0, 0, MainScreenWidth, descriptionHeight)];  
327 - }]; 319 + if (webView == relatedWebView) {
  320 + CGRect frame = relatedWebView.frame;
  321 + frame.size.width = MainScreenWidth;
  322 + frame.size.height = 1;
  323 + relatedWebView.frame = frame;
  324 + [webView evaluateJavaScript:@"document.body.scrollHeight"completionHandler:^(id _Nullable result,NSError * _Nullable error){
  325 + NSLog(@"scrollHeight高度:%.2f",[result floatValue]);
  326 + descriptionHeight = [result floatValue];
  327 + [relatedWebView setFrame:CGRectMake(0, 0, MainScreenWidth, descriptionHeight)];
  328 + }];
  329 + }
328 330
329 if (![[Reachability reachabilityForInternetConnection] currentReachabilityStatus]) { 331 if (![[Reachability reachabilityForInternetConnection] currentReachabilityStatus]) {
330 [self setUpUIWithTag:webView.tag Height:0]; 332 [self setUpUIWithTag:webView.tag Height:0];
@@ -353,8 +355,16 @@ @@ -353,8 +355,16 @@
353 frame.size.width = MainScreenWidth; 355 frame.size.width = MainScreenWidth;
354 frame.size.height = 1; 356 frame.size.height = 1;
355 relatedWebView.frame = frame; 357 relatedWebView.frame = frame;
356 - descriptionHeight = relatedWebView.scrollView.contentSize.height;  
357 - [relatedWebView setFrame:CGRectMake(0, 0, MainScreenWidth, descriptionHeight)]; 358 +// descriptionHeight = relatedWebView.scrollView.contentSize.height;
  359 + [relatedWebView evaluateJavaScript:@"document.body.scrollHeight"completionHandler:^(id _Nullable result,NSError * _Nullable error){
  360 + NSLog(@"scrollHeight高度:%.2f",[result floatValue]);
  361 + descriptionHeight = [result floatValue];
  362 + dispatch_async(dispatch_get_main_queue(), ^{
  363 + [relatedWebView setFrame:CGRectMake(0, 0, MainScreenWidth, descriptionHeight)];
  364 +
  365 + });
  366 + }];
  367 +// [relatedWebView setFrame:CGRectMake(0, 0, MainScreenWidth, descriptionHeight)];
358 lineImage1 = [[UIImageView alloc] initWithFrame:CGRectMake(0, descriptionHeight, MainScreenWidth, 1)]; 368 lineImage1 = [[UIImageView alloc] initWithFrame:CGRectMake(0, descriptionHeight, MainScreenWidth, 1)];
359 lineImage1.backgroundColor = Color_Line; 369 lineImage1.backgroundColor = Color_Line;
360 [backgroundView addSubview:lineImage1]; 370 [backgroundView addSubview:lineImage1];
@@ -433,20 +443,32 @@ @@ -433,20 +443,32 @@
433 frame.size.width = MainScreenWidth; 443 frame.size.width = MainScreenWidth;
434 frame.size.height = 1; 444 frame.size.height = 1;
435 _webView.frame = frame; 445 _webView.frame = frame;
436 - graphicLiveHeight = _webView.scrollView.contentSize.height; 446 + [_webView evaluateJavaScript:@"document.body.scrollHeight"completionHandler:^(id _Nullable result,NSError * _Nullable error){
  447 + graphicLiveHeight = [result floatValue];
  448 + if (0 == [heightArr[fontIndex] floatValue]) {
  449 + [heightArr replaceObjectAtIndex:fontIndex withObject:[NSString stringWithFormat:@"%f",graphicLiveHeight]];
  450 + }
  451 +
  452 + if (isShow) {
  453 + NSLog(@"fontIndex = %d",fontIndex);
  454 + [backgroundView setContentSize:CGSizeMake(MainScreenWidth, 40 + descriptionHeight + [heightArr[fontIndex] floatValue] + 221)];
  455 + [_webView setFrame:CGRectMake(0, 40 + descriptionHeight, MainScreenWidth, [heightArr[fontIndex] floatValue])];
  456 + [self showRelatedInformation:40 + descriptionHeight + [heightArr[fontIndex] floatValue]];
  457 + }
  458 + }];
437 459
438 NSLog(@"%@",NSStringFromCGRect(_webView.frame)); 460 NSLog(@"%@",NSStringFromCGRect(_webView.frame));
439 NSLog(@"%@",NSStringFromCGSize(_webView.scrollView.contentSize)); 461 NSLog(@"%@",NSStringFromCGSize(_webView.scrollView.contentSize));
440 - if (0 == [heightArr[fontIndex] floatValue]) {  
441 - [heightArr replaceObjectAtIndex:fontIndex withObject:[NSString stringWithFormat:@"%f",graphicLiveHeight]];  
442 - }  
443 -  
444 - if (isShow) {  
445 - NSLog(@"fontIndex = %d",fontIndex);  
446 - [backgroundView setContentSize:CGSizeMake(MainScreenWidth, 40 + descriptionHeight + [heightArr[fontIndex] floatValue] + 221)];  
447 - [_webView setFrame:CGRectMake(0, 40 + descriptionHeight, MainScreenWidth, [heightArr[fontIndex] floatValue])];  
448 - [self showRelatedInformation:40 + descriptionHeight + [heightArr[fontIndex] floatValue]];  
449 - } 462 +// if (0 == [heightArr[fontIndex] floatValue]) {
  463 +// [heightArr replaceObjectAtIndex:fontIndex withObject:[NSString stringWithFormat:@"%f",graphicLiveHeight]];
  464 +// }
  465 +//
  466 +// if (isShow) {
  467 +// NSLog(@"fontIndex = %d",fontIndex);
  468 +// [backgroundView setContentSize:CGSizeMake(MainScreenWidth, 40 + descriptionHeight + [heightArr[fontIndex] floatValue] + 221)];
  469 +// [_webView setFrame:CGRectMake(0, 40 + descriptionHeight, MainScreenWidth, [heightArr[fontIndex] floatValue])];
  470 +// [self showRelatedInformation:40 + descriptionHeight + [heightArr[fontIndex] floatValue]];
  471 +// }
450 } 472 }
451 } 473 }
452 474
CNLiveScioLive/Pages/Live/Controller/TopNoticeViewController.m
@@ -105,10 +105,18 @@ @@ -105,10 +105,18 @@
105 self.navigationItem.title = CustomStr(@"Announcements"); 105 self.navigationItem.title = CustomStr(@"Announcements");
106 } 106 }
107 - (void)setUpUI{ 107 - (void)setUpUI{
  108 + NSString *jScript = @"var meta = document.createElement('meta'); meta.setAttribute('name', 'viewport'); meta.setAttribute('content', 'width=device-width'); document.getElementsByTagName('head')[0].appendChild(meta);";
  109 +
  110 + WKUserScript *wkUScript = [[WKUserScript alloc] initWithSource:jScript injectionTime:WKUserScriptInjectionTimeAtDocumentEnd forMainFrameOnly:YES];
  111 + WKUserContentController *wkUController = [[WKUserContentController alloc] init];
  112 + [wkUController addUserScript:wkUScript];
  113 +
  114 + WKWebViewConfiguration *config = [[WKWebViewConfiguration alloc] init];
  115 + config.userContentController = wkUController;
108 if (iPhoneX) { 116 if (iPhoneX) {
109 - _webView = [[WKWebView alloc] initWithFrame:CGRectMake(0, 0, MainScreenWidth, MainScreenHeight - 88 - 44 - 34)]; 117 + _webView = [[WKWebView alloc] initWithFrame:CGRectMake(0, 0, MainScreenWidth, MainScreenHeight - 88 - 44 - 34) configuration:config];
110 } else { 118 } else {
111 - _webView = [[WKWebView alloc] initWithFrame:CGRectMake(0, 0, MainScreenWidth, MainScreenHeight - 64 - 44)]; 119 + _webView = [[WKWebView alloc] initWithFrame:CGRectMake(0, 0, MainScreenWidth, MainScreenHeight - 64 - 44) configuration:config];
112 } 120 }
113 _webView.scrollView.backgroundColor = [UIColor whiteColor]; 121 _webView.scrollView.backgroundColor = [UIColor whiteColor];
114 _webView.backgroundColor = [UIColor whiteColor]; 122 _webView.backgroundColor = [UIColor whiteColor];