func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -> Swift.Void)
{
let request = navigationAction.request; // Inspect this request to see if it's from Facebook
let policy = WKNavigationActionPolicyAllow or WKNavigationActionPolicyCancel depending if you want the request to continue firing or not
decisionHandler( policy );
}
目标-C
- (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler
{
NSURLRequest *request = navigationAction.request; // Inspect this request to see if it's from Facebook
WKNavigationActionPolicy policy = WKNavigationActionPolicyAllow or WKNavigationActionPolicyCancel depending if you want the request to continue firing or not
decisionHandler( policy );
}
1条答案
按热度按时间byqmnocz1#
您可以使用
WKWebView
的navigationDelegate
来侦听该操作。您应该实现的委托方法是:雨燕
目标-C