| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- //
- // RDSUserProtocolViewController.m
- // SmartLightForBigFish
- //
- // Created by coderYK on 2017/11/22.
- // Copyright © 2017年 RD. All rights reserved.
- //
- #import "RDSUserProtocolViewController.h"
- #import <WebKit/WebKit.h>
- @interface RDSUserProtocolViewController ()<WKUIDelegate,WKNavigationDelegate>
- @property (nonatomic, strong) WKWebView *webView;
- @end
- @implementation RDSUserProtocolViewController
- - (void)viewDidLoad {
- [super viewDidLoad];
-
- self.title = _vcTitle;
- [self p_setupUI];
-
- [self p_loadData];
-
- }
- -(void) p_loadData{
- /* 加载服务器url的方法*/
- NSString *url = self.url;
- NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:url]];
- [_webView loadRequest:request];
- }
- -(void) p_setupUI{
-
- self.webView = [[WKWebView alloc] init];
-
- // 放在AppDelegate中全局修改
- // [_webView evaluateJavaScript:@"navigator.userAgent" completionHandler:^(id _Nullable result, NSError * _Nullable error) {
- // NSString *newUserAgent = [result stringByAppendingFormat:@"/%@", @"yongxulvjian"];
- // [[NSUserDefaults standardUserDefaults] registerDefaults:@{@"UserAgent":newUserAgent}];
- // }];
-
- [self.view addSubview:_webView];
- [_webView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.view);
- make.right.equalTo(self.view);
- make.top.equalTo(self.view);
- if (@available(iOS 11.0, *)) {
- make.bottom.equalTo(self.view.mas_safeAreaLayoutGuideBottom);
- } else {
- make.bottom.equalTo(self.view.mas_bottom);
- }
- }];
- _webView.UIDelegate = self;
- _webView.navigationDelegate = self;
- _webView.allowsBackForwardNavigationGestures = YES;
-
-
-
- }
- @end
|