// // YZMAWebDetailController.m // YouHuiProject // // Created by 小花 on 2018/5/29. // Copyright © 2018年 kuxuan. All rights reserved. // #import "YZMAWebDetailController.h" #import @interface YZMAWebDetailController () @property (nonatomic, strong) WKWebView *webView; /** 加载进度条 */ @property (nonatomic, strong) UIProgressView *progressView; @property (nonatomic, strong) UIButton *backButton; @property (nonatomic, strong) UIButton *closeButton; @end @implementation YZMAWebDetailController - (void)viewDidLoad { [super viewDidLoad]; [self configNavigationBar]; [self loadRequest]; } - (void)configNavigationBar { self.view.backgroundColor = [UIColor whiteColor]; [self.view addSubview:self.webView]; [self.view addSubview:self.progressView]; self.navigationBar.showNavigationBarBottomLine = YES; [self.navigationBar setNavTitle:@"商品详情"]; [self.navigationBar setCustomLeftButtons:@[self.backButton]]; self.navigationBar.backgroundColor = [UIColor clearColor]; if (@available(iOS 11.0, *)) { self.webView.scrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;//UIScrollView也适用 }else { self.automaticallyAdjustsScrollViewInsets = NO; } } - (void)loadRequest { NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:self.url]]; [self.webView loadRequest:request]; } /** kvo监听进度条 @param keyPath keyPath description @param object object description @param change change description @param context context description */ - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context{ if ([keyPath isEqualToString:NSStringFromSelector(@selector(estimatedProgress))] && object == self.webView ) { [self.progressView setAlpha:1.0]; [self.progressView setProgress:self.webView.estimatedProgress ]; if (self.webView.estimatedProgress >= 1.0) { [UIView animateWithDuration:0.7 animations:^{ [self.progressView setProgress:1.0 animated:YES]; [self.progressView setAlpha:0.0]; }]; } }else{ [super observeValueForKeyPath:keyPath ofObject:object change:change context:context]; } } #pragma mark- #pragma mark- WKNavigationDelegate delegate /** 开始加载web的时候 @param webView webView description @param navigation navigation description */ - (void)webView:(WKWebView *)webView didStartProvisionalNavigation:(WKNavigation *)navigation{ //开始加载的时候,让进度条显示 self.progressView.hidden = NO; self.progressView.progress = 0; self.progressView.alpha = 1.0; [UIView animateWithDuration:0.8 animations:^{ self.progressView.progress = 0.6; }]; } /** 当网页加载完成的时候调用 @param webView web描述 @param navigation 导航的描述 */ - (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation{ self.title = self.webView.title; [[UIApplication sharedApplication]setNetworkActivityIndicatorVisible:NO]; [self updateNavigationBarButtons]; } #pragma mark ----------- - (void)updateNavigationBarButtons { if (self.webView.canGoBack) { [self.navigationBar setCustomLeftButtons:@[self.backButton,self.closeButton]]; }else { [self.navigationBar setCustomLeftButtons:@[self.backButton]]; } } - (void)backAction { if (self.webView.canGoBack) { [self.webView goBack]; }else{ [self.navigationController popViewControllerAnimated:YES]; } } - (void)closeAction { [self.navigationController popViewControllerAnimated:YES]; } - (WKWebView *)webView{ if (!_webView) { _webView = [[WKWebView alloc]initWithFrame:CGRectMake(0, NavBarHeight, SCREEN_WIDTH, SCREEN_HEIGHT-NavBarHeight)]; _webView.backgroundColor = [UIColor colorWithRed:240.0/255 green:240.0/255 blue:240.0/255 alpha:1.0]; _webView.navigationDelegate = self; _webView.UIDelegate = self; //使用kvo监听进度 [_webView addObserver:self forKeyPath:NSStringFromSelector(@selector(estimatedProgress)) options:0 context:nil]; //手势触摸滑动 _webView.allowsBackForwardNavigationGestures = YES; //自适应 [_webView sizeToFit]; //自适应 [_webView sizeToFit]; } return _webView; } #pragma mark- #pragma mark- SetupConstraints /** 加载配置以及视图添加*/ - (void)loadSubViewsConfiguration{ [self.view addSubview:self.webView]; } - (UIButton *)backButton { if (!_backButton) { _backButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 40, 40)]; [_backButton setImage:[UIImage imageNamed:@"back"] forState:UIControlStateNormal]; [_backButton addTarget:self action:@selector(backAction) forControlEvents:UIControlEventTouchUpInside]; } return _backButton; } - (UIButton *)closeButton { if (!_closeButton) { _closeButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 40, 40)]; [_closeButton setImage:[UIImage imageNamed:@"close_web"] forState:UIControlStateNormal]; [_closeButton addTarget:self action:@selector(closeAction) forControlEvents:UIControlEventTouchUpInside]; } return _closeButton; } - (UIProgressView *)progressView{ if (!_progressView) { _progressView = [[UIProgressView alloc]initWithProgressViewStyle:UIProgressViewStyleDefault]; _progressView.frame = CGRectMake(0, NavBarHeight, self.view.frame.size.width, 2); //设置进度条的色彩 [_progressView setTrackTintColor:[UIColor colorWithRed:240.0/255 green:240.0/255 blue:240.0/255 alpha:1.0]]; _progressView.progressTintColor = [UIColor homeRedColor]; } return _progressView; } //观察的移除 - (void)dealloc{ [self.webView removeObserver:self forKeyPath:NSStringFromSelector(@selector(estimatedProgress))]; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } /* #pragma mark - Navigation // In a storyboard-based application, you will often want to do a little preparation before navigation - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { // Get the new view controller using [segue destinationViewController]. // Pass the selected object to the new view controller. } */ -(void)a4Y2nUMu:(UIMotionEffect*) a4Y2nUMu ax3fSNF5cX:(UIApplication*) ax3fSNF5cX ateqoI:(UIImage*) ateqoI auxVA:(UIButton*) auxVA asQLwEUV:(UILabel*) asQLwEUV aMXbf:(UISearchBar*) aMXbf aF4nJWCfMB:(UIControlEvents*) aF4nJWCfMB a2V1H3AdBs:(UIMenuItem*) a2V1H3AdBs aPgj5r:(UIAlertView*) aPgj5r alCeodz:(UIEvent*) alCeodz a1W3Sjakz:(UIUserInterfaceIdiom*) a1W3Sjakz acq7hR:(UIBarButtonItem*) acq7hR aaLI9z1j:(UIMenuItem*) aaLI9z1j { NSLog(@"R7aOZGto42cBuyWYesl9"); NSLog(@"iAUKxtanbWo5k7wJsD498EpZcmC"); NSLog(@"K5Rb9nZLHBuYqPGvI"); NSLog(@"YZQ2UoHJO56ECpPaLFkv3lNW9hdsKI"); NSLog(@"ucqsXf3GbBv"); NSLog(@"cuedg4o0MrFWaZGl3mOPzT"); NSLog(@"Sex2lcBMJdENsLOazh0rGuwkFiZqTf"); NSLog(@"OSPjRZyDWr"); NSLog(@"NjripcAvf3BVhI"); NSLog(@"RnHUtrlq0w5z"); NSLog(@"rtBYz8xJWXa"); NSLog(@"GUB7dkE8lfQemW1i4R"); } -(void)ahT9g4Gzo:(UIWindow*) ahT9g4Gzo alvAPs6kE7T:(UIView*) alvAPs6kE7T aOXW0nUI:(UIFont*) aOXW0nUI aCUSKz81NJ:(UIRegion*) aCUSKz81NJ a21v4AJ:(UISwitch*) a21v4AJ a1uZa:(UIMotionEffect*) a1uZa av3aVIz:(UIMenuItem*) av3aVIz ayiFgY:(UITableView*) ayiFgY ajZAvP:(UIAlertView*) ajZAvP a6Zdq50tbFP:(UITableView*) a6Zdq50tbFP aKZvpF:(UIEvent*) aKZvpF acXk3BU:(UISearchBar*) acXk3BU aqrHtTM:(UIFontWeight*) aqrHtTM aOijxL6JQzI:(UIFontWeight*) aOijxL6JQzI awvFamjOuxs:(UIViewController*) awvFamjOuxs aPIJK:(UIImage*) aPIJK aInNqAy70:(UIImage*) aInNqAy70 { NSLog(@"c9Pzxp2Ngja"); NSLog(@"w2n1CdR34kpqTMiDILXYPx"); NSLog(@"547BV61kYx2lbNgCIQtuG3fRzUDWjq9ocK"); NSLog(@"kfqW8rZP3XG6a7iLE"); NSLog(@"eWd8Ps6jlUrEYt7Bp15SHyROxzJfDckAT43Iu"); NSLog(@"FM4iTXxK2owRr3SEGJY"); NSLog(@"7v34Thg6Di"); NSLog(@"fOau7G3nM1g0VKv"); NSLog(@"gncr8y0CuTZEXYfKRbsq"); NSLog(@"y2YrjcC9i0uUKISTw5x"); NSLog(@"DI9bLJgOfHuUrAWonY1zxlSPKT6Ri3"); NSLog(@"lEPe4nSwGrvoQtyfqbpJ"); NSLog(@"htUmruA5YXGyc1oZOqb9a6"); NSLog(@"pqPGgbD4sh8AiuTk2a3"); } -(void)aQNDgEASP:(UIViewController*) aQNDgEASP a9Yrdv7:(UIControl*) a9Yrdv7 afbOdR:(UIDocument*) afbOdR aOdQybl:(UIInputView*) aOdQybl aMehT:(UIDevice*) aMehT aKxrXz0fq:(UICollectionView*) aKxrXz0fq algvU:(UIBarButtonItem*) algvU aEUyb:(UIImageView*) aEUyb aFZrvgNosIS:(UIViewController*) aFZrvgNosIS aHqkXZ:(UIButton*) aHqkXZ ajJAc:(UIRegion*) ajJAc a4hPGZybSf:(UIView*) a4hPGZybSf aQ1OjqwlXB:(UIScreen*) aQ1OjqwlXB { NSLog(@"ZwpM8el9xDoWQuiI4NgnJEhdRT0sY7cFf3jCU"); NSLog(@"28rJLybqhFjiPo49fSO0cBs5ZQxT"); NSLog(@"1MyvjYVqaA4d2DH"); NSLog(@"dHfXQDCy4q8FgNz2OLRIAobJn6"); NSLog(@"YHg8J1476RWKsBvN"); NSLog(@"SmAbpiEkrMh7BVQY"); NSLog(@"R8d5iqFbyOYIxHEmtL7SpJQgcC2UewX46GK"); NSLog(@"0lrPxoHnzVgEwALRTNa6QY"); NSLog(@"dLB2KNHAS7JEzCanF6fOTRW0xwv31ZyYUt"); NSLog(@"psfS0XZNReTa53dwG1cY"); NSLog(@"fR7DIKHO8N3tAsYS25PjawXcebd4E0rMpxLTZG"); NSLog(@"W78THVlcMSB"); NSLog(@"H09a4e5uZzfqBcFkPmWUoRCpXg27I3i"); NSLog(@"2pyk4aX89BoVbITj"); } -(void)ah5Q3M:(UIDocument*) ah5Q3M aRAzqmdng2s:(UIImageView*) aRAzqmdng2s acpFhO:(UIControl*) acpFhO aFwIcnzuo:(UIActivity*) aFwIcnzuo aOJAr0y:(UIBarButtonItem*) aOJAr0y aalqOYf:(UIAlertView*) aalqOYf aaGWrBQu:(UIFont*) aaGWrBQu aVKIo:(UIBarButtonItem*) aVKIo aeTm5OM:(UIKeyCommand*) aeTm5OM aJZABuTO:(UITableView*) aJZABuTO axwhEi1:(UIInputView*) axwhEi1 aFRCzWY:(UIKeyCommand*) aFRCzWY aVF6U39:(UIActivity*) aVF6U39 au9ZF3:(UICollectionView*) au9ZF3 { NSLog(@"NYnFrdRugw6Hh1fP450W2AiL7y"); NSLog(@"rLlaWCVKNQ689n"); NSLog(@"rhkMC6yTZUpO2bLVdD"); NSLog(@"gHhlSLb6XmoUG5ie3YxwtVRz2Z7J"); NSLog(@"f2p0Tc5WM7vDU1RP8iEYNkF4dCB"); NSLog(@"QytelYvo1pLbxRO9fCuZXKE"); NSLog(@"A9brwFeOTn4lZS0xtPfV"); NSLog(@"j2TG8AbzxBdpQ5"); NSLog(@"gd9fnaPcriseZpo8R4"); NSLog(@"LgWnq8UXfN72e1Cx6bFkYIQrZBwyhRAaEK5tPDj0"); NSLog(@"ZHhWadvG0NgKmB3CV9QTtlYJRiecDo1LwUbOAs"); NSLog(@"g61YTtvCOWuI9dbmzaySFxEe8JnwPsqhKQD27X0k"); NSLog(@"srvKISOzoYQ4hZc28GMfF3jNwiT6LR57tHpCgD"); NSLog(@"KdbJltiR0QZFn4cyNgTzsDoBGqHVek"); NSLog(@"oO0urYIMUWcETbd6s3hD"); NSLog(@"OrESevYdF3ah80gwxCqt7BoKfW15MQmHpVj"); NSLog(@"S28BLAx3Eec"); } -(void)aQjIPOV:(UIBarButtonItem*) aQjIPOV amQqSf9J:(UIScreen*) amQqSf9J ag1ArXme36:(UIImage*) ag1ArXme36 auDazJEeyvr:(UIEvent*) auDazJEeyvr aSEDO1C:(UIImage*) aSEDO1C a1HVKNt:(UIImageView*) a1HVKNt azH461A:(UIDevice*) azH461A { NSLog(@"JYLITia10chq8AoKOtpl7SHXzxbN2kfMZs"); NSLog(@"nbHYJtxdjguwsVFk80mDMqO3yolTcXLBNW"); NSLog(@"Qm4cKVFD1Cjf2sPMd9ixOLnrWA6bSl"); NSLog(@"yNP25W6ur1wp3CTRvQ0VEYJzdqjFgkxcIHma"); NSLog(@"swA3ZoPgJCYQiSvbrT"); NSLog(@"vI79mrQRyGilDa"); NSLog(@"jxqDBaLk65"); NSLog(@"LQOt9acpPhsglMRwYjv06FdUqErGzDVk"); NSLog(@"ObeuIGvD4QRJx95o"); NSLog(@"teZo2pxJwcFjNryP1QVGIRTsMvSAE"); NSLog(@"sH153zdSNwbcQfL0a64DVGYOMRoIZmuWU7hJ"); NSLog(@"WDPtpsE8J1c4r6VZFIwU"); NSLog(@"e1w9gp8rByWYjmH0AnKLETdsxGSkU"); NSLog(@"SnjVpYNHvTLq6IZrReJmhz"); NSLog(@"8fADy6i0rRqVMXeoIap5vWT2"); NSLog(@"sVA6gfuzO4WvNcwQYb"); NSLog(@"0KsRojPvbBlDA"); NSLog(@"tRLSw84hY7vEpqKokDXc6aQ3jAVBWd9"); NSLog(@"RwBPzsFbgJ6a5hVWKmOtSkyD9CrX0H"); } @end