Commit 99ec55741945fba8c5c76d1c129ec1c0e14bdbc5
1 parent
3e56ecec
添加h5,去验证主播
Showing
2 changed files
with
108 additions
and
0 deletions
LiveVideoCloud/Classes/Sections/LiveSections/Controller/LVCVerifyViewController.h
0 → 100644
LiveVideoCloud/Classes/Sections/LiveSections/Controller/LVCVerifyViewController.m
0 → 100644
| 1 | +// | |
| 2 | +// LVCVerifyViewController.m | |
| 3 | +// LiveVideoCloud | |
| 4 | +// | |
| 5 | +// Created by cnliveJunBo on 17/5/17. | |
| 6 | +// Copyright © 2017年 cnlive. All rights reserved. | |
| 7 | +// | |
| 8 | + | |
| 9 | +#import "LVCVerifyViewController.h" | |
| 10 | +#import <WebKit/WebKit.h> | |
| 11 | + | |
| 12 | +@interface LVCVerifyViewController ()<WKUIDelegate, WKNavigationDelegate> | |
| 13 | + | |
| 14 | +@end | |
| 15 | + | |
| 16 | +@implementation LVCVerifyViewController | |
| 17 | + | |
| 18 | +- (void)viewDidLoad { | |
| 19 | + [super viewDidLoad]; | |
| 20 | + | |
| 21 | + self.view.backgroundColor = [UIColor blueColor]; | |
| 22 | + | |
| 23 | + WKWebView *webView = [[WKWebView alloc]init]; | |
| 24 | + [self.view addSubview:webView]; | |
| 25 | + [webView mas_makeConstraints:^(MASConstraintMaker *make) { | |
| 26 | + make.top.equalTo(self.view).offset(64); | |
| 27 | + make.left.right.bottom.equalTo(self.view); | |
| 28 | + }]; | |
| 29 | + webView.UIDelegate = self; | |
| 30 | + webView.navigationDelegate = self; | |
| 31 | + [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"https://mobile.cnlive.com/CnliveMobile/web/review/review.jsp"]]]; | |
| 32 | + | |
| 33 | +} | |
| 34 | + | |
| 35 | +#pragma mark - WKNavigationDelegate | |
| 36 | +// 页面开始加载时调用 | |
| 37 | +- (void)webView:(WKWebView *)webView didStartProvisionalNavigation:(WKNavigation *)navigation{ | |
| 38 | + | |
| 39 | +} | |
| 40 | +// 当内容开始返回时调用 | |
| 41 | +- (void)webView:(WKWebView *)webView didCommitNavigation:(WKNavigation *)navigation{ | |
| 42 | + | |
| 43 | +} | |
| 44 | +// 页面加载完成之后调用 | |
| 45 | +- (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation{ | |
| 46 | + | |
| 47 | +} | |
| 48 | +// 页面加载失败时调用 | |
| 49 | +- (void)webView:(WKWebView *)webView didFailProvisionalNavigation:(WKNavigation *)navigation{ | |
| 50 | + | |
| 51 | + [Tools showHUDInView:self.view withString:@"加载失败,请稍后重试..." autoHide:YES]; | |
| 52 | +} | |
| 53 | +// 接收到服务器跳转请求之后调用 | |
| 54 | +- (void)webView:(WKWebView *)webView didReceiveServerRedirectForProvisionalNavigation:(WKNavigation *)navigation{ | |
| 55 | + | |
| 56 | +} | |
| 57 | +// 在收到响应后,决定是否跳转 | |
| 58 | +- (void)webView:(WKWebView *)webView decidePolicyForNavigationResponse:(WKNavigationResponse *)navigationResponse decisionHandler:(void (^)(WKNavigationResponsePolicy))decisionHandler{ | |
| 59 | + | |
| 60 | + NSLog(@"%@",navigationResponse.response.URL.absoluteString); | |
| 61 | + //允许跳转 | |
| 62 | + decisionHandler(WKNavigationResponsePolicyAllow); | |
| 63 | + //不允许跳转 | |
| 64 | + //decisionHandler(WKNavigationResponsePolicyCancel); | |
| 65 | +} | |
| 66 | +// 在发送请求之前,决定是否跳转 | |
| 67 | +- (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler{ | |
| 68 | + | |
| 69 | + NSLog(@"%@",navigationAction.request.URL.absoluteString); | |
| 70 | + //允许跳转 | |
| 71 | + decisionHandler(WKNavigationActionPolicyAllow); | |
| 72 | + //不允许跳转 | |
| 73 | + //decisionHandler(WKNavigationActionPolicyCancel); | |
| 74 | +} | |
| 75 | +#pragma mark - WKUIDelegate | |
| 76 | +// 创建一个新的WebView | |
| 77 | +- (WKWebView *)webView:(WKWebView *)webView createWebViewWithConfiguration:(WKWebViewConfiguration *)configuration forNavigationAction:(WKNavigationAction *)navigationAction windowFeatures:(WKWindowFeatures *)windowFeatures{ | |
| 78 | + return [[WKWebView alloc]init]; | |
| 79 | +} | |
| 80 | +// 输入框 | |
| 81 | +- (void)webView:(WKWebView *)webView runJavaScriptTextInputPanelWithPrompt:(NSString *)prompt defaultText:(nullable NSString *)defaultText initiatedByFrame:(WKFrameInfo *)frame completionHandler:(void (^)(NSString * __nullable result))completionHandler{ | |
| 82 | + completionHandler(@"http"); | |
| 83 | +} | |
| 84 | +// 确认框 | |
| 85 | +- (void)webView:(WKWebView *)webView runJavaScriptConfirmPanelWithMessage:(NSString *)message initiatedByFrame:(WKFrameInfo *)frame completionHandler:(void (^)(BOOL result))completionHandler{ | |
| 86 | + completionHandler(YES); | |
| 87 | +} | |
| 88 | +// 警告框 | |
| 89 | +- (void)webView:(WKWebView *)webView runJavaScriptAlertPanelWithMessage:(NSString *)message initiatedByFrame:(WKFrameInfo *)frame completionHandler:(void (^)(void))completionHandler{ | |
| 90 | + NSLog(@"%@",message); | |
| 91 | + completionHandler(); | |
| 92 | +} | |
| 93 | + | |
| 94 | + | |
| 95 | +@end | ... | ... |