ADLinkVC.m 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. @interface ADLinkVC ()<WKNavigationDelegate>
  11. @end
  12. @implementation ADLinkVC
  13. - (void)viewDidLoad {
  14. [super viewDidLoad];
  15. self.view.backgroundColor = [UIColor whiteColor];
  16. [self configNavigationBar];
  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.height = kSize.height - kNavOffSet;
  26. view.navigationDelegate = self;
  27. [self.view addSubview: view];
  28. NSURLRequest *request = [[NSURLRequest alloc] initWithURL:[NSURL URLWithString:_urlString]];
  29. if (![Util connectedToNetWork]) {
  30. showMsgUnconnect();
  31. return;
  32. }
  33. [MBProgressHUD showLoadToView:self.view];
  34. [view loadRequest:request];
  35. }
  36. #pragma mark -
  37. // 页面加载失败时调用
  38. - (void)webView:(WKWebView *)webView didFailProvisionalNavigation:(null_unspecified WKNavigation *)navigation withError:(NSError *)error{
  39. [MBProgressHUD hideHUDForView:self.view];
  40. }
  41. // 页面加载完毕时调用
  42. - (void)webView:(WKWebView *)webView didFinishNavigation:(null_unspecified WKNavigation *)navigation{
  43. [MBProgressHUD hideHUDForView:self.view];
  44. }
  45. - (void)didReceiveMemoryWarning {
  46. [super didReceiveMemoryWarning];
  47. // Dispose of any resources that can be recreated.
  48. }
  49. /*
  50. #pragma mark - Navigation
  51. // In a storyboard-based application, you will often want to do a little preparation before navigation
  52. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  53. // Get the new view controller using [segue destinationViewController].
  54. // Pass the selected object to the new view controller.
  55. }
  56. */
  57. @end