如何给wkwebview添加navigationbar返回上一层
1个回答
2016-08-03
展开全部
/**
* 在发送请求之前,决定是否跳转
*
* @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);
}
* 在发送请求之前,决定是否跳转
*
* @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);
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询