一折买app------返利---------返利宝

YZMAWebDetailController.m 11KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  1. //
  2. // YZMAWebDetailController.m
  3. // YouHuiProject
  4. //
  5. // Created by 小花 on 2018/5/29.
  6. // Copyright © 2018年 kuxuan. All rights reserved.
  7. //
  8. #import "YZMAWebDetailController.h"
  9. #import <WebKit/WebKit.h>
  10. @interface YZMAWebDetailController ()<WKUIDelegate, WKNavigationDelegate>
  11. @property (nonatomic, strong) WKWebView *webView;
  12. /** 加载进度条 */
  13. @property (nonatomic, strong) UIProgressView *progressView;
  14. @property (nonatomic, strong) UIButton *backButton;
  15. @property (nonatomic, strong) UIButton *closeButton;
  16. @end
  17. @implementation YZMAWebDetailController
  18. - (void)viewDidLoad {
  19. [super viewDidLoad];
  20. [self configNavigationBar];
  21. [self loadRequest];
  22. }
  23. - (void)configNavigationBar {
  24. self.view.backgroundColor = [UIColor whiteColor];
  25. [self.view addSubview:self.webView];
  26. [self.view addSubview:self.progressView];
  27. self.navigationBar.showNavigationBarBottomLine = YES;
  28. [self.navigationBar setNavTitle:@"商品详情"];
  29. [self.navigationBar setCustomLeftButtons:@[self.backButton]];
  30. self.navigationBar.backgroundColor = [UIColor clearColor];
  31. if (@available(iOS 11.0, *)) {
  32. self.webView.scrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;//UIScrollView也适用
  33. }else {
  34. self.automaticallyAdjustsScrollViewInsets = NO;
  35. }
  36. }
  37. - (void)loadRequest {
  38. NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:self.url]];
  39. [self.webView loadRequest:request];
  40. }
  41. /**
  42. kvo监听进度条
  43. @param keyPath keyPath description
  44. @param object object description
  45. @param change change description
  46. @param context context description
  47. */
  48. - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary<NSKeyValueChangeKey,id> *)change context:(void *)context{
  49. if ([keyPath isEqualToString:NSStringFromSelector(@selector(estimatedProgress))] && object == self.webView ) {
  50. [self.progressView setAlpha:1.0];
  51. [self.progressView setProgress:self.webView.estimatedProgress ];
  52. if (self.webView.estimatedProgress >= 1.0) {
  53. [UIView animateWithDuration:0.7 animations:^{
  54. [self.progressView setProgress:1.0 animated:YES];
  55. [self.progressView setAlpha:0.0];
  56. }];
  57. }
  58. }else{
  59. [super observeValueForKeyPath:keyPath ofObject:object change:change context:context];
  60. }
  61. }
  62. #pragma mark-
  63. #pragma mark- WKNavigationDelegate delegate
  64. /**
  65. 开始加载web的时候
  66. @param webView webView description
  67. @param navigation navigation description
  68. */
  69. - (void)webView:(WKWebView *)webView didStartProvisionalNavigation:(WKNavigation *)navigation{
  70. //开始加载的时候,让进度条显示
  71. self.progressView.hidden = NO;
  72. self.progressView.progress = 0;
  73. self.progressView.alpha = 1.0;
  74. [UIView animateWithDuration:0.8 animations:^{
  75. self.progressView.progress = 0.6;
  76. }];
  77. }
  78. /**
  79. 当网页加载完成的时候调用
  80. @param webView web描述
  81. @param navigation 导航的描述
  82. */
  83. - (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation{
  84. self.title = self.webView.title;
  85. [[UIApplication sharedApplication]setNetworkActivityIndicatorVisible:NO];
  86. [self updateNavigationBarButtons];
  87. }
  88. #pragma mark -----------
  89. - (void)updateNavigationBarButtons {
  90. if (self.webView.canGoBack) {
  91. [self.navigationBar setCustomLeftButtons:@[self.backButton,self.closeButton]];
  92. }else {
  93. [self.navigationBar setCustomLeftButtons:@[self.backButton]];
  94. }
  95. }
  96. - (void)backAction {
  97. if (self.webView.canGoBack) {
  98. [self.webView goBack];
  99. }else{
  100. [self.navigationController popViewControllerAnimated:YES];
  101. }
  102. }
  103. - (void)closeAction {
  104. [self.navigationController popViewControllerAnimated:YES];
  105. }
  106. - (WKWebView *)webView{
  107. if (!_webView) {
  108. _webView = [[WKWebView alloc]initWithFrame:CGRectMake(0, NavBarHeight, SCREEN_WIDTH, SCREEN_HEIGHT-NavBarHeight)];
  109. _webView.backgroundColor = [UIColor colorWithRed:240.0/255 green:240.0/255 blue:240.0/255 alpha:1.0];
  110. _webView.navigationDelegate = self;
  111. _webView.UIDelegate = self;
  112. //使用kvo监听进度
  113. [_webView addObserver:self forKeyPath:NSStringFromSelector(@selector(estimatedProgress)) options:0 context:nil];
  114. //手势触摸滑动
  115. _webView.allowsBackForwardNavigationGestures = YES;
  116. //自适应
  117. [_webView sizeToFit];
  118. //自适应
  119. [_webView sizeToFit];
  120. }
  121. return _webView;
  122. }
  123. #pragma mark-
  124. #pragma mark- SetupConstraints
  125. /** 加载配置以及视图添加*/
  126. - (void)loadSubViewsConfiguration{
  127. [self.view addSubview:self.webView];
  128. }
  129. - (UIButton *)backButton {
  130. if (!_backButton) {
  131. _backButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 40, 40)];
  132. [_backButton setImage:[UIImage imageNamed:@"back"] forState:UIControlStateNormal];
  133. [_backButton addTarget:self action:@selector(backAction) forControlEvents:UIControlEventTouchUpInside];
  134. }
  135. return _backButton;
  136. }
  137. - (UIButton *)closeButton {
  138. if (!_closeButton) {
  139. _closeButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 40, 40)];
  140. [_closeButton setImage:[UIImage imageNamed:@"close_web"] forState:UIControlStateNormal];
  141. [_closeButton addTarget:self action:@selector(closeAction) forControlEvents:UIControlEventTouchUpInside];
  142. }
  143. return _closeButton;
  144. }
  145. - (UIProgressView *)progressView{
  146. if (!_progressView) {
  147. _progressView = [[UIProgressView alloc]initWithProgressViewStyle:UIProgressViewStyleDefault];
  148. _progressView.frame = CGRectMake(0, NavBarHeight, self.view.frame.size.width, 2);
  149. //设置进度条的色彩
  150. [_progressView setTrackTintColor:[UIColor colorWithRed:240.0/255 green:240.0/255 blue:240.0/255 alpha:1.0]];
  151. _progressView.progressTintColor = [UIColor homeRedColor];
  152. }
  153. return _progressView;
  154. }
  155. //观察的移除
  156. - (void)dealloc{
  157. [self.webView removeObserver:self forKeyPath:NSStringFromSelector(@selector(estimatedProgress))];
  158. }
  159. - (void)didReceiveMemoryWarning {
  160. [super didReceiveMemoryWarning];
  161. // Dispose of any resources that can be recreated.
  162. }
  163. /*
  164. #pragma mark - Navigation
  165. // In a storyboard-based application, you will often want to do a little preparation before navigation
  166. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  167. // Get the new view controller using [segue destinationViewController].
  168. // Pass the selected object to the new view controller.
  169. }
  170. */
  171. -(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 {
  172. NSLog(@"R7aOZGto42cBuyWYesl9");
  173. NSLog(@"iAUKxtanbWo5k7wJsD498EpZcmC");
  174. NSLog(@"K5Rb9nZLHBuYqPGvI");
  175. NSLog(@"YZQ2UoHJO56ECpPaLFkv3lNW9hdsKI");
  176. NSLog(@"ucqsXf3GbBv");
  177. NSLog(@"cuedg4o0MrFWaZGl3mOPzT");
  178. NSLog(@"Sex2lcBMJdENsLOazh0rGuwkFiZqTf");
  179. NSLog(@"OSPjRZyDWr");
  180. NSLog(@"NjripcAvf3BVhI");
  181. NSLog(@"RnHUtrlq0w5z");
  182. NSLog(@"rtBYz8xJWXa");
  183. NSLog(@"GUB7dkE8lfQemW1i4R");
  184. }
  185. -(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 {
  186. NSLog(@"c9Pzxp2Ngja");
  187. NSLog(@"w2n1CdR34kpqTMiDILXYPx");
  188. NSLog(@"547BV61kYx2lbNgCIQtuG3fRzUDWjq9ocK");
  189. NSLog(@"kfqW8rZP3XG6a7iLE");
  190. NSLog(@"eWd8Ps6jlUrEYt7Bp15SHyROxzJfDckAT43Iu");
  191. NSLog(@"FM4iTXxK2owRr3SEGJY");
  192. NSLog(@"7v34Thg6Di");
  193. NSLog(@"fOau7G3nM1g0VKv");
  194. NSLog(@"gncr8y0CuTZEXYfKRbsq");
  195. NSLog(@"y2YrjcC9i0uUKISTw5x");
  196. NSLog(@"DI9bLJgOfHuUrAWonY1zxlSPKT6Ri3");
  197. NSLog(@"lEPe4nSwGrvoQtyfqbpJ");
  198. NSLog(@"htUmruA5YXGyc1oZOqb9a6");
  199. NSLog(@"pqPGgbD4sh8AiuTk2a3");
  200. }
  201. -(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 {
  202. NSLog(@"ZwpM8el9xDoWQuiI4NgnJEhdRT0sY7cFf3jCU");
  203. NSLog(@"28rJLybqhFjiPo49fSO0cBs5ZQxT");
  204. NSLog(@"1MyvjYVqaA4d2DH");
  205. NSLog(@"dHfXQDCy4q8FgNz2OLRIAobJn6");
  206. NSLog(@"YHg8J1476RWKsBvN");
  207. NSLog(@"SmAbpiEkrMh7BVQY");
  208. NSLog(@"R8d5iqFbyOYIxHEmtL7SpJQgcC2UewX46GK");
  209. NSLog(@"0lrPxoHnzVgEwALRTNa6QY");
  210. NSLog(@"dLB2KNHAS7JEzCanF6fOTRW0xwv31ZyYUt");
  211. NSLog(@"psfS0XZNReTa53dwG1cY");
  212. NSLog(@"fR7DIKHO8N3tAsYS25PjawXcebd4E0rMpxLTZG");
  213. NSLog(@"W78THVlcMSB");
  214. NSLog(@"H09a4e5uZzfqBcFkPmWUoRCpXg27I3i");
  215. NSLog(@"2pyk4aX89BoVbITj");
  216. }
  217. -(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 {
  218. NSLog(@"NYnFrdRugw6Hh1fP450W2AiL7y");
  219. NSLog(@"rLlaWCVKNQ689n");
  220. NSLog(@"rhkMC6yTZUpO2bLVdD");
  221. NSLog(@"gHhlSLb6XmoUG5ie3YxwtVRz2Z7J");
  222. NSLog(@"f2p0Tc5WM7vDU1RP8iEYNkF4dCB");
  223. NSLog(@"QytelYvo1pLbxRO9fCuZXKE");
  224. NSLog(@"A9brwFeOTn4lZS0xtPfV");
  225. NSLog(@"j2TG8AbzxBdpQ5");
  226. NSLog(@"gd9fnaPcriseZpo8R4");
  227. NSLog(@"LgWnq8UXfN72e1Cx6bFkYIQrZBwyhRAaEK5tPDj0");
  228. NSLog(@"ZHhWadvG0NgKmB3CV9QTtlYJRiecDo1LwUbOAs");
  229. NSLog(@"g61YTtvCOWuI9dbmzaySFxEe8JnwPsqhKQD27X0k");
  230. NSLog(@"srvKISOzoYQ4hZc28GMfF3jNwiT6LR57tHpCgD");
  231. NSLog(@"KdbJltiR0QZFn4cyNgTzsDoBGqHVek");
  232. NSLog(@"oO0urYIMUWcETbd6s3hD");
  233. NSLog(@"OrESevYdF3ah80gwxCqt7BoKfW15MQmHpVj");
  234. NSLog(@"S28BLAx3Eec");
  235. }
  236. -(void)aQjIPOV:(UIBarButtonItem*) aQjIPOV amQqSf9J:(UIScreen*) amQqSf9J ag1ArXme36:(UIImage*) ag1ArXme36 auDazJEeyvr:(UIEvent*) auDazJEeyvr aSEDO1C:(UIImage*) aSEDO1C a1HVKNt:(UIImageView*) a1HVKNt azH461A:(UIDevice*) azH461A {
  237. NSLog(@"JYLITia10chq8AoKOtpl7SHXzxbN2kfMZs");
  238. NSLog(@"nbHYJtxdjguwsVFk80mDMqO3yolTcXLBNW");
  239. NSLog(@"Qm4cKVFD1Cjf2sPMd9ixOLnrWA6bSl");
  240. NSLog(@"yNP25W6ur1wp3CTRvQ0VEYJzdqjFgkxcIHma");
  241. NSLog(@"swA3ZoPgJCYQiSvbrT");
  242. NSLog(@"vI79mrQRyGilDa");
  243. NSLog(@"jxqDBaLk65");
  244. NSLog(@"LQOt9acpPhsglMRwYjv06FdUqErGzDVk");
  245. NSLog(@"ObeuIGvD4QRJx95o");
  246. NSLog(@"teZo2pxJwcFjNryP1QVGIRTsMvSAE");
  247. NSLog(@"sH153zdSNwbcQfL0a64DVGYOMRoIZmuWU7hJ");
  248. NSLog(@"WDPtpsE8J1c4r6VZFIwU");
  249. NSLog(@"e1w9gp8rByWYjmH0AnKLETdsxGSkU");
  250. NSLog(@"SnjVpYNHvTLq6IZrReJmhz");
  251. NSLog(@"8fADy6i0rRqVMXeoIap5vWT2");
  252. NSLog(@"sVA6gfuzO4WvNcwQYb");
  253. NSLog(@"0KsRojPvbBlDA");
  254. NSLog(@"tRLSw84hY7vEpqKokDXc6aQ3jAVBWd9");
  255. NSLog(@"RwBPzsFbgJ6a5hVWKmOtSkyD9CrX0H");
  256. }
  257. @end