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 79  
80 80 }
81 81  
  82 +- (UIStatusBarStyle)preferredStatusBarStyle {
  83 + UIViewController *vc = self.topViewController;
  84 + return [vc preferredStatusBarStyle];
  85 +}
  86 +
82 87 @end
... ...
CNLiveScioLive/Pages/Base/CNLiveBaseViewController.m
... ... @@ -186,4 +186,9 @@
186 186 return UIInterfaceOrientationMaskPortrait;
187 187  
188 188 }
  189 +
  190 +- (UIStatusBarStyle)preferredStatusBarStyle {
  191 + return UIStatusBarStyleDefault;
  192 +}
  193 +
189 194 @end
... ...
CNLiveScioLive/Pages/Home/新闻详情/OldController/BaseViewController.m
... ... @@ -25,4 +25,8 @@
25 25 return UIInterfaceOrientationMaskPortrait;
26 26 }
27 27  
  28 +- (UIStatusBarStyle)preferredStatusBarStyle {
  29 + return UIStatusBarStyleLightContent;
  30 +}
  31 +
28 32 @end
... ...
CNLiveScioLive/Pages/Home/新闻详情/OldController/OldArticleDetailViewController.h
... ... @@ -22,6 +22,6 @@
22 22 @property (strong, nonatomic) NSArray *newsArray;
23 23 @property (strong, nonatomic) WKWebView *webView;
24 24 @property (strong, nonatomic) UITableView *tableView;
25   -@property (strong, nonatomic) UIScrollView *scrollView;
26 25 -(id)initWithDictionary:(NSDictionary*)dictionary;
  26 +
27 27 @end
... ...
CNLiveScioLive/Pages/Home/新闻详情/OldController/OldArticleDetailViewController.m
... ... @@ -44,7 +44,7 @@
44 44 }
45 45 return self;
46 46 }
47   -- (NSString *)setHTMLString:(NSString *)content {
  47 +- (NSString *)setHTMLString:(NSString *)content author:(NSString *)author {
48 48 NSString* htmlcontent = [[NSString alloc] initWithFormat:
49 49 @"<!doctype html>\n"
50 50 "<html>\n"
... ... @@ -65,7 +65,7 @@
65 65 "</script>\n"
66 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 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 69 // NSString * htmlcontent = [NSString stringWithFormat:@"<div id=\"webview_content_wrapper\">%@<font style=\"font-size:%@px;\">%@</font></div>",htmlHeader,fontArray[fontIndex],content];
70 70 NSLog(@"htmlcontent = %@",htmlcontent);
71 71 return htmlcontent;
... ... @@ -87,7 +87,7 @@
87 87 NSDictionary *dic = [NSDictionary dictionaryWithDictionary:responseObject];
88 88 // NSLog(@"%@",dic);
89 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 91 isFail = 0;
92 92 _refresh.hidden = YES;
93 93  
... ... @@ -122,6 +122,7 @@
122 122 parameters:parameters headers:nil
123 123 progress:^(NSProgress * _Nonnull uploadProgress) {}
124 124 success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
  125 + self.tableView.hidden = NO;
125 126 // 请求成功,解析数据
126 127 NSDictionary *_dic = [NSDictionary dictionaryWithDictionary:responseObject];
127 128 NSLog(@"%@",_dic);
... ... @@ -130,9 +131,6 @@
130 131 NSArray *array = _dic[@"programs"];
131 132 if (0 != [array count]) {
132 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 134 [self.tableView reloadData];
137 135 }
138 136 } else {
... ... @@ -221,6 +219,16 @@
221 219 [self.view addSubview:shareButton];
222 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 232 - (void)shareButtonTaped:(id)sender {
225 233 UIButton *btn = (UIButton *)sender;
226 234 if (10000 == btn.tag) {
... ... @@ -231,13 +239,19 @@
231 239 }
232 240 if (0 == fontIndex) {
233 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 245 } else if (1 == fontIndex) {
236 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 250 } else if (2 == fontIndex) {
239 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 256 } else if (20000 == btn.tag) {
243 257 TableData *notice = [[TableData alloc] initWithJSONDictionary:_dictionary];
... ... @@ -272,15 +286,6 @@
272 286  
273 287 self.view.backgroundColor = [UIColor whiteColor];
274 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 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 296 WKWebViewConfiguration *wkWebConfig = [[WKWebViewConfiguration alloc] init];
292 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 300 _webView.scrollView.backgroundColor = [UIColor whiteColor];
300 301 _webView.scrollView.showsVerticalScrollIndicator = NO;
301 302 _webView.backgroundColor = [UIColor whiteColor];
302 303 _webView.navigationDelegate = self;
303 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 313 self.tableView.backgroundColor = [UIColor whiteColor];
308   - self.tableView.backgroundView = nil;
309   - self.tableView.scrollEnabled = NO;
310 314 self.tableView.dataSource = self;
311 315 self.tableView.delegate = self;
312   - [self.scrollView addSubview:self.tableView];
  316 + [self.view addSubview:self.tableView];
  317 +
313 318 self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
314 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 322 self.tableView.hidden = YES;
319 323  
320 324  
... ... @@ -322,7 +326,7 @@
322 326 self.errorLabe.backgroundColor = [UIColor clearColor];
323 327 self.errorLabe.textColor = HEXCOLOR(0x333333);
324 328 self.errorLabe.font = [UIFont systemFontOfSize:15];
325   - [self.scrollView addSubview:self.errorLabe];
  329 + [self.view addSubview:self.errorLabe];
326 330 self.errorLabe.text = @"没有数据";
327 331 self.errorLabe.hidden = YES;
328 332  
... ... @@ -478,17 +482,10 @@
478 482 NSString *javascriptWithCSSString = [NSString stringWithFormat:javascriptString, cssString];
479 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 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 489 if (!hasLoad) {
493 490 [self loadProgramRelativeData];
494 491 }
... ... @@ -592,18 +589,23 @@
592 589 -(void)viewDidLayoutSubviews{
593 590 if ([self.tableView respondsToSelector:@selector(setSeparatorInset:)])
594 591 [self.tableView setSeparatorInset:UIEdgeInsetsMake(0,0,0,0)];
595   -
  592 +
596 593 if ([self.tableView respondsToSelector:@selector(setLayoutMargins:)])
597 594 [self.tableView setLayoutMargins:UIEdgeInsetsMake(0,0,0,0)];
598 595 }
599 596 -(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath{
600 597 if ([cell respondsToSelector:@selector(setSeparatorInset:)])
601 598 [cell setSeparatorInset:UIEdgeInsetsZero];
602   -
  599 +
603 600 if ([cell respondsToSelector:@selector(setLayoutMargins:)])
604 601 [cell setLayoutMargins:UIEdgeInsetsZero];
605 602 }
606 603 - (void)didReceiveMemoryWarning{
607 604 [super didReceiveMemoryWarning];
608 605 }
  606 +
  607 +- (UIStatusBarStyle)preferredStatusBarStyle {
  608 + return UIStatusBarStyleLightContent;
  609 +}
  610 +
609 611 @end
... ...
CNLiveScioLive/Pages/Live/Controller/GraphicLiveViewController.m
... ... @@ -525,7 +525,8 @@
525 525 frame.origin.y = y;
526 526 frame.size.height = height;
527 527 [relatedInformationView setFrame:frame];
528   -
  528 + [backgroundView setContentSize:CGSizeMake(MainScreenWidth, relatedInformationView.bottom)];
  529 +
529 530 }
530 531 - (void)showGraphicLive:(id)sender {
531 532 isShow = !isShow;
... ...
CNLiveScioLive/Pages/SDK/XLSlideMenu/XLSlideMenu.m
... ... @@ -325,4 +325,10 @@ static CGFloat MinActionSpeed = 500;
325 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 334 @end
... ...