From f35cb784f7edb05b113494e86a00268ef902ae89 Mon Sep 17 00:00:00 2001 From: 重庆迈尖科技有限公司 Date: 星期三, 18 八月 2021 14:03:27 +0800 Subject: [PATCH] 3.1.2完善 --- BuWanVideo2.0/WEBViewController.m | 19 +++++++++++++++++-- 1 files changed, 17 insertions(+), 2 deletions(-) diff --git a/BuWanVideo2.0/WEBViewController.m b/BuWanVideo2.0/WEBViewController.m index dda865c..0b5e889 100755 --- a/BuWanVideo2.0/WEBViewController.m +++ b/BuWanVideo2.0/WEBViewController.m @@ -15,6 +15,7 @@ @property (strong, nonatomic) WKWebView *webView; @property (strong, nonatomic) UILabel *titleView; +@property (strong, nonatomic) UILabel *urlView; @property (strong, nonatomic) UIButton *backBt; @property (strong, nonatomic) UIButton *reloadBt; @@ -30,6 +31,12 @@ _titleView.backgroundColor=kGlobalMainColor; _titleView.userInteractionEnabled=YES; [self.view addSubview:_titleView]; + //娣诲姞缃戦〉閾炬帴 + _urlView=[[UILabel alloc] initWithFrame:CGRectMake(50, 34, KScreenW-100, 24)]; + [_urlView setFont:[UIFont systemFontOfSize:12]]; + [_urlView setTextColor:[UIColor whiteColor]]; + _urlView.userInteractionEnabled=YES; + [self.view addSubview:_urlView]; //缃戦〉瑙嗗浘 _webView=[[WKWebView alloc] initWithFrame:CGRectMake(0, 64, KScreenW, KScreenH-64)]; @@ -69,9 +76,14 @@ [_reloadBt addTarget:self action:@selector(reloadButtonPushed:) forControlEvents:UIControlEventTouchUpInside]; [self.view addSubview:_reloadBt]; + + //鐩戝惉鏍囬 [_webView addObserver:self forKeyPath:@"title" options:NSKeyValueObservingOptionNew context:NULL]; [_webView addObserver:self forKeyPath:@"estimatedProgress" options:NSKeyValueObservingOptionNew context:NULL]; + + + [self loadwebViews]; } @@ -117,6 +129,7 @@ -(void)loadwebViews{ NSURLRequest *req = [[NSURLRequest alloc] initWithURL:[NSURL URLWithString:_url]]; [_webView loadRequest:req]; + _urlView.text=_url; } @@ -145,6 +158,7 @@ NSString *url; url = navigationAction.request.URL.absoluteString; NSLog(@"閾炬帴锛�%@",url); + if([url hasPrefix:@"iqiyi"]){ if ([[UIApplication sharedApplication] @@ -183,6 +197,7 @@ //鏀寔鐨勬柟鍚� 鍥犱负鐣岄潰A鎴戜滑鍙渶瑕佹敮鎸佺珫灞� - (UIInterfaceOrientationMask)supportedInterfaceOrientations{ _titleView.frame=CGRectMake(0, 0, KScreenWp, 64); + _urlView.frame=CGRectMake(50, 34, KScreenWp-100, 24); _webView.frame=CGRectMake(0, 64, KScreenWp, KScreenHp-64); _backBt.frame=CGRectMake(8, 22, 32, 32); _reloadBt.frame=CGRectMake(KScreenWp-40, 22, 32, 32); @@ -194,10 +209,10 @@ if (object == _webView) { NSString *title = _webView.title; if(webtitle==nil){ - webtitle=[[UILabel alloc] initWithFrame:CGRectMake(50, 22, KScreenW-100, 32)]; + webtitle=[[UILabel alloc] initWithFrame:CGRectMake(50, 15, KScreenW-100, 32)]; [webtitle setFont:[UIFont systemFontOfSize:14]]; [webtitle setTextColor:[UIColor whiteColor]]; - [webtitle setTextAlignment:NSTextAlignmentCenter]; + [webtitle setTextAlignment:NSTextAlignmentLeft]; [_titleView addSubview:webtitle]; } webtitle.text =title; -- Gitblit v1.8.0