Created
September 4, 2017 02:33
-
-
Save kikohz/e14bbba1b13007181619c63d121cfa59 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 在发送请求之前,决定是否跳转 | |
* | |
* @param webView 实现该代理的webview | |
* @param navigationAction 当前navigation | |
* @param decisionHandler 是否调转block | |
*/ | |
- (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler { | |
if (navigationAction.navigationType==WKNavigationTypeBackForward) { //判断是返回类型 | |
if (webView.backForwardList.backList.count>0) { //得到栈里面的list | |
WKBackForwardListItem * item = webView.backForwardList.currentItem; //得到现在加载的list | |
for (WKBackForwardListItem * backItem inwebView.backForwardList.backList) { //循环遍历,得到你想退出到 | |
//添加判断条件 | |
[webView goToBackForwardListItem:[webView.backForwardList.backListfirstObject]]; | |
} | |
} | |
} | |
//允许跳转 | |
decisionHandler(WKNavigationActionPolicyAllow); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment