ADLinkVC.m 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. //
  2. // ADLinkVC.m
  3. // jiaPei
  4. //
  5. // Created by apple on 16/4/26.
  6. // Copyright © 2016年 JCZ. All rights reserved.
  7. //
  8. #import "ADLinkVC.h"
  9. #import <WebKit/WebKit.h>
  10. #import <MBProgressHUD.h>
  11. @interface ADLinkVC ()<WKNavigationDelegate>
  12. @end
  13. @implementation ADLinkVC
  14. - (void)viewDidLoad {
  15. [super viewDidLoad];
  16. self.view.backgroundColor = [UIColor whiteColor];
  17. self.tabBarController.tabBar.hidden = YES;
  18. if (_urlString.length > 0) {
  19. [self creatWebView];
  20. }
  21. }
  22. -(void)creatWebView
  23. {
  24. WKWebView *view = [[WKWebView alloc] initWithFrame:kFrame];
  25. view.navigationDelegate = self;
  26. [self.view addSubview: view];
  27. NSURLRequest *request = [[NSURLRequest alloc] initWithURL:[NSURL URLWithString:_urlString]];
  28. [MBProgressHUD showHUDAddedTo:self.view animated:NO];
  29. [view loadRequest:request];
  30. }
  31. #pragma mark -
  32. // 页面加载失败时调用
  33. - (void)webView:(WKWebView *)webView didFailProvisionalNavigation:(null_unspecified WKNavigation *)navigation withError:(NSError *)error{
  34. [MBProgressHUD hideHUDForView:self.view animated:NO];
  35. }
  36. // 页面加载完毕时调用
  37. - (void)webView:(WKWebView *)webView didFinishNavigation:(null_unspecified WKNavigation *)navigation{
  38. [MBProgressHUD hideHUDForView:self.view animated:NO];
  39. }
  40. - (void)didReceiveMemoryWarning {
  41. [super didReceiveMemoryWarning];
  42. // Dispose of any resources that can be recreated.
  43. }
  44. /*
  45. #pragma mark - Navigation
  46. // In a storyboard-based application, you will often want to do a little preparation before navigation
  47. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  48. // Get the new view controller using [segue destinationViewController].
  49. // Pass the selected object to the new view controller.
  50. }
  51. */
  52. @end