Commit 7a21740dba13038d3c98d0d2706c1a7db10dd27d

Authored by 张旭
2 parents 100faf35 5baabc11

Merge branch 'master' of bj.gitlab.cnlive.com:ios-team/ScioLive

CNLiveScioLive/Pages/Base/CNLiveBaseNavigationController.m
@@ -79,4 +79,9 @@ @@ -79,4 +79,9 @@
79 79
80 } 80 }
81 81
  82 +- (UIStatusBarStyle)preferredStatusBarStyle {
  83 + UIViewController *vc = self.topViewController;
  84 + return [vc preferredStatusBarStyle];
  85 +}
  86 +
82 @end 87 @end
CNLiveScioLive/Pages/Base/CNLiveBaseViewController.m
@@ -186,4 +186,9 @@ @@ -186,4 +186,9 @@
186 return UIInterfaceOrientationMaskPortrait; 186 return UIInterfaceOrientationMaskPortrait;
187 187
188 } 188 }
  189 +
  190 +- (UIStatusBarStyle)preferredStatusBarStyle {
  191 + return UIStatusBarStyleDefault;
  192 +}
  193 +
189 @end 194 @end
CNLiveScioLive/Pages/Home/新闻详情/OldController/BaseViewController.m
@@ -25,4 +25,8 @@ @@ -25,4 +25,8 @@
25 return UIInterfaceOrientationMaskPortrait; 25 return UIInterfaceOrientationMaskPortrait;
26 } 26 }
27 27
  28 +- (UIStatusBarStyle)preferredStatusBarStyle {
  29 + return UIStatusBarStyleLightContent;
  30 +}
  31 +
28 @end 32 @end
CNLiveScioLive/Pages/Home/新闻详情/OldController/OldArticleDetailViewController.h
@@ -22,6 +22,6 @@ @@ -22,6 +22,6 @@
22 @property (strong, nonatomic) NSArray *newsArray; 22 @property (strong, nonatomic) NSArray *newsArray;
23 @property (strong, nonatomic) WKWebView *webView; 23 @property (strong, nonatomic) WKWebView *webView;
24 @property (strong, nonatomic) UITableView *tableView; 24 @property (strong, nonatomic) UITableView *tableView;
25 -@property (strong, nonatomic) UIScrollView *scrollView;  
26 -(id)initWithDictionary:(NSDictionary*)dictionary; 25 -(id)initWithDictionary:(NSDictionary*)dictionary;
  26 +
27 @end 27 @end
CNLiveScioLive/Pages/Home/新闻详情/OldController/OldArticleDetailViewController.m
@@ -44,7 +44,7 @@ @@ -44,7 +44,7 @@
44 } 44 }
45 return self; 45 return self;
46 } 46 }
47 -- (NSString *)setHTMLString:(NSString *)content { 47 +- (NSString *)setHTMLString:(NSString *)content author:(NSString *)author {
48 NSString* htmlcontent = [[NSString alloc] initWithFormat: 48 NSString* htmlcontent = [[NSString alloc] initWithFormat:
49 @"<!doctype html>\n" 49 @"<!doctype html>\n"
50 "<html>\n" 50 "<html>\n"
@@ -65,7 +65,7 @@ @@ -65,7 +65,7 @@
65 "</script>\n" 65 "</script>\n"
66 "<div id=\"webview_content\"><p><font style=\"font-size:20px;\"><strong>%@</strong></font><p>%@</p><font color=\"#184085\">%@</font></p><div><font style=\"font-size:%@px;\">%@</font></div></div>" 66 "<div id=\"webview_content\"><p><font style=\"font-size:20px;\"><strong>%@</strong></font><p>%@</p><font color=\"#184085\">%@</font></p><div><font style=\"font-size:%@px;\">%@</font></div></div>"
67 "</body>" 67 "</body>"
68 - "</html>",[_dictionary objectForKey:@"title"],[_dictionary objectForKey:@"createDate"],@"来源 : 国新网",fontArray[fontIndex],content]; 68 + "</html>",[_dictionary objectForKey:@"title"],[_dictionary objectForKey:@"createDate"],[NSString stringWithFormat:@"来源:%@",author?author:@"国新网"],fontArray[fontIndex],content];
69 // NSString * htmlcontent = [NSString stringWithFormat:@"<div id=\"webview_content_wrapper\">%@<font style=\"font-size:%@px;\">%@</font></div>",htmlHeader,fontArray[fontIndex],content]; 69 // NSString * htmlcontent = [NSString stringWithFormat:@"<div id=\"webview_content_wrapper\">%@<font style=\"font-size:%@px;\">%@</font></div>",htmlHeader,fontArray[fontIndex],content];
70 NSLog(@"htmlcontent = %@",htmlcontent); 70 NSLog(@"htmlcontent = %@",htmlcontent);
71 return htmlcontent; 71 return htmlcontent;
@@ -87,7 +87,7 @@ @@ -87,7 +87,7 @@
87 NSDictionary *dic = [NSDictionary dictionaryWithDictionary:responseObject]; 87 NSDictionary *dic = [NSDictionary dictionaryWithDictionary:responseObject];
88 // NSLog(@"%@",dic); 88 // NSLog(@"%@",dic);
89 if ([dic[@"errorCode"] isEqualToString:@"0"]) { 89 if ([dic[@"errorCode"] isEqualToString:@"0"]) {
90 - [_webView loadHTMLString:[self setHTMLString:dic[@"content"]] baseURL:nil]; 90 + [_webView loadHTMLString:[self setHTMLString:dic[@"content"] author:dic[@"author"]] baseURL:nil];
91 isFail = 0; 91 isFail = 0;
92 _refresh.hidden = YES; 92 _refresh.hidden = YES;
93 93
@@ -122,6 +122,7 @@ @@ -122,6 +122,7 @@
122 parameters:parameters headers:nil 122 parameters:parameters headers:nil
123 progress:^(NSProgress * _Nonnull uploadProgress) {} 123 progress:^(NSProgress * _Nonnull uploadProgress) {}
124 success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) { 124 success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
  125 + self.tableView.hidden = NO;
125 // 请求成功,解析数据 126 // 请求成功,解析数据
126 NSDictionary *_dic = [NSDictionary dictionaryWithDictionary:responseObject]; 127 NSDictionary *_dic = [NSDictionary dictionaryWithDictionary:responseObject];
127 NSLog(@"%@",_dic); 128 NSLog(@"%@",_dic);
@@ -130,9 +131,6 @@ @@ -130,9 +131,6 @@
130 NSArray *array = _dic[@"programs"]; 131 NSArray *array = _dic[@"programs"];
131 if (0 != [array count]) { 132 if (0 != [array count]) {
132 self->_newsArray = [NSArray arrayWithArray:array]; 133 self->_newsArray = [NSArray arrayWithArray:array];
133 - [self.tableView setFrame:CGRectMake(0, [self->heightArr[self->fontIndex] floatValue], MainScreenWidth, 36 + 86 * self->_newsArray.count)];  
134 - [self.scrollView setContentSize:CGSizeMake(MainScreenWidth, [self->heightArr[self->fontIndex] floatValue] + self.tableView.frame.size.height)];  
135 - self.tableView.hidden = NO;  
136 [self.tableView reloadData]; 134 [self.tableView reloadData];
137 } 135 }
138 } else { 136 } else {
@@ -221,6 +219,16 @@ @@ -221,6 +219,16 @@
221 [self.view addSubview:shareButton]; 219 [self.view addSubview:shareButton];
222 [shareButton setTag:30000]; 220 [shareButton setTag:30000];
223 } 221 }
  222 +- (void)getWebViewHeight{
  223 + [_webView evaluateJavaScript:@"document.body.scrollHeight" completionHandler:^(id _Nullable result, NSError * _Nullable error){
  224 + CGFloat graphicLiveHeight = [result floatValue];
  225 + _webView.height = graphicLiveHeight+30;
  226 + UIView *view = self.tableView. tableHeaderView;
  227 + [view sizeToFit];
  228 + view.frame = CGRectMake(0, 0, MainScreenWidth, _webView.height);
  229 + [self.tableView reloadData];
  230 + }];
  231 +}
224 - (void)shareButtonTaped:(id)sender { 232 - (void)shareButtonTaped:(id)sender {
225 UIButton *btn = (UIButton *)sender; 233 UIButton *btn = (UIButton *)sender;
226 if (10000 == btn.tag) { 234 if (10000 == btn.tag) {
@@ -231,13 +239,19 @@ @@ -231,13 +239,19 @@
231 } 239 }
232 if (0 == fontIndex) { 240 if (0 == fontIndex) {
233 NSLog(@"0"); 241 NSLog(@"0");
234 - [_webView evaluateJavaScript:@"document.getElementsByTagName('body')[0].style.webkitTextSizeAdjust= '100%'" completionHandler:nil]; 242 + [_webView evaluateJavaScript:@"document.getElementsByTagName('body')[0].style.webkitTextSizeAdjust= '100%'" completionHandler:^(id _Nullable res, NSError * _Nullable error) {
  243 + [self getWebViewHeight];
  244 + }];
235 } else if (1 == fontIndex) { 245 } else if (1 == fontIndex) {
236 NSLog(@"1"); 246 NSLog(@"1");
237 - [_webView evaluateJavaScript:@"document.getElementsByTagName('body')[0].style.webkitTextSizeAdjust= '120%'" completionHandler:nil]; 247 + [_webView evaluateJavaScript:@"document.getElementsByTagName('body')[0].style.webkitTextSizeAdjust= '120%'" completionHandler:^(id _Nullable res, NSError * _Nullable error) {
  248 + [self getWebViewHeight];
  249 + }];
238 } else if (2 == fontIndex) { 250 } else if (2 == fontIndex) {
239 NSLog(@"2"); 251 NSLog(@"2");
240 - [_webView evaluateJavaScript:@"document.getElementsByTagName('body')[0].style.webkitTextSizeAdjust= '140%'" completionHandler:nil]; 252 + [_webView evaluateJavaScript:@"document.getElementsByTagName('body')[0].style.webkitTextSizeAdjust= '140%'" completionHandler:^(id _Nullable res, NSError * _Nullable error) {
  253 + [self getWebViewHeight];
  254 + }];
241 } 255 }
242 } else if (20000 == btn.tag) { 256 } else if (20000 == btn.tag) {
243 TableData *notice = [[TableData alloc] initWithJSONDictionary:_dictionary]; 257 TableData *notice = [[TableData alloc] initWithJSONDictionary:_dictionary];
@@ -272,15 +286,6 @@ @@ -272,15 +286,6 @@
272 286
273 self.view.backgroundColor = [UIColor whiteColor]; 287 self.view.backgroundColor = [UIColor whiteColor];
274 [self setUpNavigationBar]; 288 [self setUpNavigationBar];
275 -  
276 - if (iPhoneX) {  
277 - self.scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, MainScreenWidth, MainScreenHeight - 88 - 44 - 34)];  
278 - } else {  
279 - self.scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, MainScreenWidth, MainScreenHeight - 64 - 44)];  
280 - }  
281 -  
282 - self.scrollView.backgroundColor = [UIColor whiteColor];  
283 - [self.view addSubview:self.scrollView];  
284 289
285 NSString *jScript = @"var meta = document.createElement('meta'); meta.setAttribute('name', 'viewport'); meta.setAttribute('content', 'width=device-width'); document.getElementsByTagName('head')[0].appendChild(meta);"; 290 NSString *jScript = @"var meta = document.createElement('meta'); meta.setAttribute('name', 'viewport'); meta.setAttribute('content', 'width=device-width'); document.getElementsByTagName('head')[0].appendChild(meta);";
286 291
@@ -291,30 +296,29 @@ @@ -291,30 +296,29 @@
291 WKWebViewConfiguration *wkWebConfig = [[WKWebViewConfiguration alloc] init]; 296 WKWebViewConfiguration *wkWebConfig = [[WKWebViewConfiguration alloc] init];
292 wkWebConfig.userContentController = wkUController; 297 wkWebConfig.userContentController = wkUController;
293 298
294 - if (iPhoneX) {  
295 - _webView = [[WKWebView alloc] initWithFrame:CGRectMake(0, 0, MainScreenWidth, MainScreenHeight - 88 - 44 - 34) configuration:wkWebConfig];  
296 - } else {  
297 - _webView = [[WKWebView alloc] initWithFrame:CGRectMake(0, 0, MainScreenWidth, MainScreenHeight - 64 - 44) configuration:wkWebConfig];  
298 - } 299 + _webView = [[WKWebView alloc] initWithFrame:CGRectMake(0, 0, MainScreenWidth, 1) configuration:wkWebConfig];
299 _webView.scrollView.backgroundColor = [UIColor whiteColor]; 300 _webView.scrollView.backgroundColor = [UIColor whiteColor];
300 _webView.scrollView.showsVerticalScrollIndicator = NO; 301 _webView.scrollView.showsVerticalScrollIndicator = NO;
301 _webView.backgroundColor = [UIColor whiteColor]; 302 _webView.backgroundColor = [UIColor whiteColor];
302 _webView.navigationDelegate = self; 303 _webView.navigationDelegate = self;
303 _webView.UIDelegate = self; 304 _webView.UIDelegate = self;
304 - [self.scrollView addSubview:_webView];  
305 -  
306 - self.tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStyleGrouped]; 305 + _webView.scrollView.scrollEnabled = NO;
  306 + _webView.opaque = NO;
  307 + if (iPhoneX) {
  308 + self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, MainScreenWidth, MainScreenHeight - 88 - 44 - 34) style:UITableViewStyleGrouped];
  309 +
  310 + } else {
  311 + self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, MainScreenWidth, MainScreenHeight - 64 - 44) style:UITableViewStyleGrouped];
  312 + }
307 self.tableView.backgroundColor = [UIColor whiteColor]; 313 self.tableView.backgroundColor = [UIColor whiteColor];
308 - self.tableView.backgroundView = nil;  
309 - self.tableView.scrollEnabled = NO;  
310 self.tableView.dataSource = self; 314 self.tableView.dataSource = self;
311 self.tableView.delegate = self; 315 self.tableView.delegate = self;
312 - [self.scrollView addSubview:self.tableView]; 316 + [self.view addSubview:self.tableView];
  317 +
313 self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone; 318 self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
314 self.tableView.showsVerticalScrollIndicator = NO; 319 self.tableView.showsVerticalScrollIndicator = NO;
315 - if ([self.tableView respondsToSelector:@selector(setSeparatorInset:)]) {  
316 - [self.tableView setSeparatorInset:UIEdgeInsetsZero];  
317 - } 320 +
  321 + self.tableView.tableHeaderView = _webView;
318 self.tableView.hidden = YES; 322 self.tableView.hidden = YES;
319 323
320 324
@@ -322,7 +326,7 @@ @@ -322,7 +326,7 @@
322 self.errorLabe.backgroundColor = [UIColor clearColor]; 326 self.errorLabe.backgroundColor = [UIColor clearColor];
323 self.errorLabe.textColor = HEXCOLOR(0x333333); 327 self.errorLabe.textColor = HEXCOLOR(0x333333);
324 self.errorLabe.font = [UIFont systemFontOfSize:15]; 328 self.errorLabe.font = [UIFont systemFontOfSize:15];
325 - [self.scrollView addSubview:self.errorLabe]; 329 + [self.view addSubview:self.errorLabe];
326 self.errorLabe.text = @"没有数据"; 330 self.errorLabe.text = @"没有数据";
327 self.errorLabe.hidden = YES; 331 self.errorLabe.hidden = YES;
328 332
@@ -478,17 +482,10 @@ @@ -478,17 +482,10 @@
478 NSString *javascriptWithCSSString = [NSString stringWithFormat:javascriptString, cssString]; 482 NSString *javascriptWithCSSString = [NSString stringWithFormat:javascriptString, cssString];
479 [webView evaluateJavaScript:javascriptWithCSSString completionHandler:nil]; 483 [webView evaluateJavaScript:javascriptWithCSSString completionHandler:nil];
480 484
481 - [webView evaluateJavaScript:@"document.body.scrollHeight" completionHandler:^(id _Nullable result,NSError * _Nullable error){ 485 + [webView evaluateJavaScript:@"document.body.scrollHeight" completionHandler:^(id _Nullable result, NSError * _Nullable error){
482 CGFloat graphicLiveHeight = [result floatValue]; 486 CGFloat graphicLiveHeight = [result floatValue];
483 - CGRect frame = _webView.frame;  
484 - frame.size.height = _webView.scrollView.contentSize.height;  
485 - _webView.frame = frame;  
486 - if (0 == [heightArr[fontIndex] floatValue]) {  
487 - [heightArr replaceObjectAtIndex:fontIndex withObject:[NSString stringWithFormat:@"%f",graphicLiveHeight]];  
488 - }  
489 - [self.scrollView.mj_header endRefreshing];  
490 - [_webView setFrame:CGRectMake(0, 0, MainScreenWidth, [heightArr[fontIndex] floatValue])];  
491 - [self.scrollView setContentSize:CGSizeMake(MainScreenWidth, [heightArr[fontIndex] floatValue])]; 487 + _webView.height = graphicLiveHeight+30;
  488 + [self.tableView reloadData];
492 if (!hasLoad) { 489 if (!hasLoad) {
493 [self loadProgramRelativeData]; 490 [self loadProgramRelativeData];
494 } 491 }
@@ -592,18 +589,23 @@ @@ -592,18 +589,23 @@
592 -(void)viewDidLayoutSubviews{ 589 -(void)viewDidLayoutSubviews{
593 if ([self.tableView respondsToSelector:@selector(setSeparatorInset:)]) 590 if ([self.tableView respondsToSelector:@selector(setSeparatorInset:)])
594 [self.tableView setSeparatorInset:UIEdgeInsetsMake(0,0,0,0)]; 591 [self.tableView setSeparatorInset:UIEdgeInsetsMake(0,0,0,0)];
595 - 592 +
596 if ([self.tableView respondsToSelector:@selector(setLayoutMargins:)]) 593 if ([self.tableView respondsToSelector:@selector(setLayoutMargins:)])
597 [self.tableView setLayoutMargins:UIEdgeInsetsMake(0,0,0,0)]; 594 [self.tableView setLayoutMargins:UIEdgeInsetsMake(0,0,0,0)];
598 } 595 }
599 -(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath{ 596 -(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath{
600 if ([cell respondsToSelector:@selector(setSeparatorInset:)]) 597 if ([cell respondsToSelector:@selector(setSeparatorInset:)])
601 [cell setSeparatorInset:UIEdgeInsetsZero]; 598 [cell setSeparatorInset:UIEdgeInsetsZero];
602 - 599 +
603 if ([cell respondsToSelector:@selector(setLayoutMargins:)]) 600 if ([cell respondsToSelector:@selector(setLayoutMargins:)])
604 [cell setLayoutMargins:UIEdgeInsetsZero]; 601 [cell setLayoutMargins:UIEdgeInsetsZero];
605 } 602 }
606 - (void)didReceiveMemoryWarning{ 603 - (void)didReceiveMemoryWarning{
607 [super didReceiveMemoryWarning]; 604 [super didReceiveMemoryWarning];
608 } 605 }
  606 +
  607 +- (UIStatusBarStyle)preferredStatusBarStyle {
  608 + return UIStatusBarStyleLightContent;
  609 +}
  610 +
609 @end 611 @end
CNLiveScioLive/Pages/Live/Controller/GraphicLiveViewController.m
@@ -525,7 +525,8 @@ @@ -525,7 +525,8 @@
525 frame.origin.y = y; 525 frame.origin.y = y;
526 frame.size.height = height; 526 frame.size.height = height;
527 [relatedInformationView setFrame:frame]; 527 [relatedInformationView setFrame:frame];
528 - 528 + [backgroundView setContentSize:CGSizeMake(MainScreenWidth, relatedInformationView.bottom)];
  529 +
529 } 530 }
530 - (void)showGraphicLive:(id)sender { 531 - (void)showGraphicLive:(id)sender {
531 isShow = !isShow; 532 isShow = !isShow;
CNLiveScioLive/Pages/SDK/XLSlideMenu/XLSlideMenu.m
@@ -325,4 +325,10 @@ static CGFloat MinActionSpeed = 500; @@ -325,4 +325,10 @@ static CGFloat MinActionSpeed = 500;
325 [super didReceiveMemoryWarning]; 325 [super didReceiveMemoryWarning];
326 } 326 }
327 327
  328 +- (UIStatusBarStyle)preferredStatusBarStyle {
  329 + UITabBarController *tabbar = (UITabBarController *)self.rootViewController;
  330 + UIViewController *vc = tabbar.selectedViewController;
  331 + return [vc preferredStatusBarStyle];
  332 +}
  333 +
328 @end 334 @end