//加载web界面
转自:http://www.brighttj.com/ios/ios-wkwebview-new-features-and-use.html
WKWebView*wWKWebView alloc] initWithFrame:self.view.bounds];
[webViewloadRequest:[NSURLRequest requestWithURL:[NSURLURLWithString:@"https://www.baidu.com"]]];
[self.view addSubview:webView];
WKNavigationDelegate
WKWebViewConfiguration*config = [[WKWebViewConfiguration alloc]init];
//页面开始加载时调用
- (void)webView:(WKWebView*)webView didStartProvisionalNavigation:(WKNavigation *)navigation;
//当内容开始返回时调用
- (void)webView:(WKWebView*)webView didCommitNavigation:(WKNavigation *)navigation;
//页面加载完成之后调用
- (void)webView:(WKWebView*)webView didFinishNavigation:(WKNavigation *)navigation;
//页面加载失败时调用
- (void)webView:(WKWebView*)webView didFailProvisionalNavigation:(WKNavigation *)navigation;
//接收到服务器跳转请求之后调用
- (void)webView:(WKWebView*)webView didReceiveServerRedirectForProvisionalNavigation:(WKNavigation*)navigation;
//在收到响应后,决定是否跳转
- (void)webView:(WKWebView
*)webView decidePolicyForNavigationResponse:(WKNavigationResponse
*)navigationResponse decisionHandler:(void(^)(WKNavigationResponsePolicy))decisionHandler;
//在发送请求之前,决定是否跳转
- (void)webView:(WKWebView
*)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction
decisionHandler:(void(^)(WKNavigationActionPolicy))decisionHandler;
WKUIDelegate
self.webView.UIDelegate
= self;
//创建一个新的WebView
- (WKWebView*)webView:(WKWebView *)webViewcreateWebViewWithConfiguration:(WKWebViewConfiguration *)configurationforNavigationAction:(WKNavigationAction *)navigationActionwindowFeatures:(WKWindowFeatures *)windowFeatures;
/**
*web界面中有弹出警告框时调用
*
*@param webView实现该代理的webview
*@param message警告框中的内容
*@param frame主窗口
*@param completionHandler警告框消失调用
*/
- (void)webView:(WKWebView
*)webView runJavaScriptAlertPanelWithMessage:(NSString*)message
initiatedByFrame:(void(^)())completionHandler;